I've below JSON
structure
{
"a": "aVal",
"x": {
"x1": "x1Val",
"x2": "x2Val"
}
"y": {
"y1": "y1Val"
}
}
I want to add "x3": "x3Val","x4": "x4Val"
to x
. So the output should be
{
...
"x": {
....
"x3": "x3Val",
"x4": "x4Val",
}
...
}
Is it possible using jq ?
Of course, it's pretty simple for jq
:
jq '.x += {"x3": "x3Val","x4": "x4Val"}' file.json
The output:
{
"a": "aVal",
"x": {
"x1": "x1Val",
"x2": "x2Val",
"x3": "x3Val",
"x4": "x4Val"
},
"y": {
"y1": "y1Val"
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments