'Using variable to ask for key in JSON object

I'm trying to build a flow that uses a JSON data structure (Let's call it Test). I'm trying to ask for the value in a given key using a variable declared previously in the flow, however, when I try something like:

variables('Test')?[variables('Texto')]

Test contains two key-value pairs, and Texto contains a string with one of the keys. When I run the flow I get this:

enter image description here

Which is not an error, but it doesn't allow me to see the inputs or outputs (the download links send me to empty pages), but given the simplicity of the exercise, I was expecting to see the value associated with the right key in the JSON.

Any help will be greatly appreciated.



Solution 1:[1]

Rather than using Compose, try just setting/initializing a variable instead.

As an example, I created an object variable using the following JSON ...

{
  "Field1": "Value 1",
  "Field2": "Value 2"
}

I then set a string variable with the value Field1 ...

Variable

Then in the next step, I used the same sort of expression as you ...

variables('JSON')?[variables('Dynamic Field Name')]

... and got the following result ...

Result

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Skin