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"
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With