Reputation: 4472
Say I have an object like so:
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
I want to use jq
to convert this to:
{
"key1": {
"innerkey": "value1"
},
"key2": {
"innerkey": "value2"
},
"key3": {
"innerkey": "value3"
}
}
i.e. I want to apply a mapping to every value in the object, that converts $value
to {"innerkey": $value}
. How can I achieve this with jq
?
Upvotes: 1
Views: 468
Reputation: 134811
You could also use the fact that iterating over an object iterates its values. So you could update those values on the object.
.[] |= {innerkey:.}
Upvotes: 0