Home > Software design >  How to replace multine values to empty string in linux?
How to replace multine values to empty string in linux?

Time:07-19

enter image description here

I wanted to change this value

{
"data":"correctValue",
  "attributes": [
    {
      "otherValue": "incorrectValue"
    }
  ]
}

to

{
"data":"correctValue"
}

CodePudding user response:

Use jq to process json files. You want to remove attributes in the top level object, which can be achieved by

jq 'del(.attributes)' file.json

CodePudding user response:

Or, if instead of deleting the attributes you want to keep .data, you can do:

jq '{data: .data}' input-file
  • Related