0

I have a JSON structure as follows:

{
      "key1": {
        "isSecret": null,
        "value": "value1"
      },
      "key2": {
        "isSecret": null,
        "value": "value2"
      },
      "key3": {
        "isSecret": null,
        "value": "value3"
}

Is it possible to use JMESPath to transform it to:

key1=value1 key2=value2 key3=value3

The only solution I found is to separately extract a list of keys and values using the following expressions:

keys([0].variables)|join(' ', @)
[0].variables.*.value|join(' ', @)

and then merge them using a script but I was wondering if there was a more direct and elegant solution in JMESPath.

Thanks in advance!

user3124206
  • 375
  • 1
  • 7
  • 16
  • Does this answer your question? [How to combine two arrays (\`keys\` and \`values\`) into an object using JMESPath?](https://stackoverflow.com/questions/31900580/how-to-combine-two-arrays-keys-and-values-into-an-object-using-jmespath) – β.εηοιτ.βε Aug 14 '23 at 16:17
  • Not quite, what they mean in that question by keys are not JSON keys but an array – user3124206 Aug 14 '23 at 17:33
  • Which Is what you get with you actual expression `keys([0].variables)|join(' ', @)`, so, yup you have the same problem as them and there is no solution either. – β.εηοιτ.βε Aug 14 '23 at 18:13

0 Answers0