skip to Main Content

Sorting a JSON file by outer object name

I have a json file input.json thus: { "foo":{ "prefix":"abc", "body":[1,2,3] }, "bar":{ "prefix":"def", "body":[4,5,6] } } I would like to sort it by the outer object names, with "bar" coming before "foo" in alphabetical order like so: { "bar":{…

VIEW QUESTION

Json – Update fields from string in JQ

I have a bash $string containing the values: abc,def and a file.json looking like this: [ { "loc": "51.12345, 12.12345", "city": "CityName1" }, { "loc": "65.12345, 15.12345", "city": "CityName2" } ] I'm trying to update the city field with the…

VIEW QUESTION

Json – JQ adding count of nested array objects to CSV

Working with a nested arrays like this: [ { "value1": "Data1-0", "value2": "Data2-0", "nArray": [ {"nValue1": "nData1-0a","nValue2": "nData2-0a"}, {"nValue1": "nData1-0b","nValue2": "nData2-0a"}, {"nValue1": "nData1-0c","nValue2": "nData2-0a"} ], "value3": "Data3-0" }, { "value1": "Data1-1", "value2": "Data2-1", "nArray": [ {"nValue1": "nData1-1a","nValue2": "nData2-1a"}, {"nValue1": "nData1-1b","nValue2":…

VIEW QUESTION

Json – get a value with jq by matching one of parent value from a variable

I have JSON data as below, in services.json { "checkout-serviceA":{"prId":6644,"Sourcebranch":"","HFX":false,"IS_CR":"Yes"}, "checkout-serviceB":{"prId":15826,"Sourcebranch":"","HFX":false,"IS_CR": "no"}, "checkout-toggle":{"prId":8963,"Sourcebranch":"","HFX":true,"IS_CR": "Yes"}, "checkout-res":{"prId":1104,"Sourcebranch":"","HFX":false,"IS_CR": "Yes"} } I have a variable eg $PRID that contains prID value already. I want to pass this to jq and fetch or get an…

VIEW QUESTION
Back To Top
Search