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