How to convert key's value from dictionary to a new key in JMESPath?

Viewed 26

How to achieve following using JMESPath?

Input:

[
   {"letter": "A", "word": "Apple"},
   {"letter": "B", "word": "Ball"},
   {"letter": "C", "word": "Cat"}
]

Expected Output:

[
   {"A": "Apple"},
   {"B": "Ball"},
   {"C": "Cat"}
]

I have tried the following, but, it does not work for key while it works for value:

[].{@.letter: @.word}

Fairly a simple requirement, should be a small thing I am missing here.

0 Answers
Related