I have the following JSON object:
{
...,
"projects": [
"abc",
"xyz"
],
...
}
And I want it transformed to:
{
"abc": {
"name": "abc"
},
"xyz": {
"name": "xyz"
},
}
I’m having trouble creating this. I’ve tried using map
as .projects | map({(.): { "name": (.) }} )
but it’s not in the format I want and ends up in an array.
2
Answers
You’re looking for something like this:
Online demo
I have a bit of a functional mindset, so I’d reach for
reduce
here:outputs