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’v tried using map
as .projects | map({(.): { "name": (.) }} )
but it’s not in the format i want and ends up in an array.
>Solution :
You’re looking for something like this:
.projects | map({(.): {name: .}}) | add