How to sort a json file by keys and values of those keys in jq
We're building a website using the Pentaho CTools library, which has a graphical dashboard editor which writes out JSON-format files for part of the dashboard.I'd like to apply a transform to these...
View ArticleHow to check if element exists in array with jq
I have an array and I need to check if elements exists in that array or to get that element from the array using jq, fruit.json:{"fruit": ["apple", "orange","pomegranate","apricot","mango" ]}cat...
View ArticleHow to get JQ to retain comma separation between matched records in the output
I'm attempting to use windows cmder.exe (or standard command prompt) to execute jq commands for command-line JSON processor to transform and output existing JSON files I have saved. I've had success...
View Articlejq group by both outer and inner value within arrays
My data is in the following simplified format[ {"a": "foo","b": [ {"x": 1,"y": true } ] }, {"a": "foo","b": [ {"x": 1,"y": true }, {"x": 99,"y": false } ] }, {"a": "bar","b": [] }]I am trying to get...
View ArticleJQ and Multiple Fields with a SELECT
Let's say I have json returned as such:export json_string='{"summary": "1 failure","checks": [ {"id": "check1","status": "OK" }, {"id": "check2","status": "FAILED" }, {"id": "check3","status":...
View ArticleIs there a way to batch split a file by chapter with ffmpeg and then...
So I made a batch script originally with the ability to relatively precision trim a video into chapters without having to run by keyframes, but the code looks horrible and I can't get it to loop...
View Articlejq: 'empty' variable leads to empty output - is it expected behavior?
In my understanding unused variable in jq query shouldn't affect output, for example this echoes it's input: "bla" as $str | .".However, empty as $var | . produces no output. Is it expected?
View ArticleParse error when text is split on multi lines: "control characters from...
I'm getting a "parse error" when I split a text line on multiple lines and show the JSON file on screen with the command jq . words.json.The JSON file with the text value on a single line looks like...
View ArticleHow do I update a single value in a json document using jq?
Appologies if I've overlooked something very obvious; I've just found jq and am trying to use it to update one JSON value without affecting the surrounding data.I'd like to pipe a curl result into jq,...
View ArticleJSON, key-value-pairs in groups to "flat" key-value-pair
Each key of a JSON should be combined with _ (or any valid JSON symbol). To have a simple key-value list.I have the following structure. A few JSON groups (no arrays), inside the groups there are...
View ArticleConcat 2 fields in JSON using jq
I am using jq to reformat my JSON.JSON String:{"channel": "youtube", "profile_type": "video", "member_key": "hello"}Wanted output:{"channel" : "profile_type.youtube"}My command:echo '{"channel":...
View ArticleParsing JSON record-per-line with jq?
I've got a tool that outputs a JSON record on each line, and I'd like to process it with jq.The output looks something like...
View ArticleAssigning an Array Parsed With jq to Bash Script Array
I parsed a json file with jq like this : # cat test.json | jq '.logs' | jq '.[]' | jq '._id' | jq -sIt returns an array like this : [34,235,436,546,.....]Using bash script i described an array : #...
View ArticleUsing jq, convert array of objects to object with named keys
Given a json file in the format as :[ { name : "A", value : "1" }, { name : "B", value : "5" }, { name : "E", value : "8" }]How would I convert it to something like this using jq:{"A" : { name : "A",...
View ArticleSplit a JSON file into separate files
I have a large JSON file that is an object of objects, which I would like to split into separate files name after object keys. Is it possible to achieve this using jq or any other off-the-shelf...
View ArticleFlatten multi-level JSON to CSV output
I am working on a jq utility on Linux to process JSON file and convert it into a CSV format. I have the following JSON with multi-level hierarchy which I want to flatten into CSV:{"totalJobCount":...
View ArticleExtract csv from klipfolio table
How can I use a bash script to extract the data from this klipfolio table into a csv file?https://app.klipfolio.com/published/6b16ab677623c60708ba3ef462e6ad8e/football-victoria-referee-appointmentsAll...
View ArticleHow to filter jCal with jq?
I have a jCal JSON array which I'd like to filter with jq. JSON arrays are somewhat new to me and I have been banging my head to the wall on this for hours...The file looks like this:["vcalendar", [...
View ArticleJQ - List Objects Where Key Is in a list
$ cat data.txt [ {"PublicIpAddress": "i1.i2.i3","InstanceId": "o1.o2.o3" }, {"PublicIpAddress": "i4.i5.i6","InstanceId": "o4.o5.o6" }, {"PublicIpAddress": "i7.i8.i9","InstanceId": "o7.o8.o9" },...
View ArticleParsing nested JSON data with jq
I have JSON data that looks like this:[ {"class": "class1","year": "year1","subject": [ {"id": 7654,"type": "subject","module": {"id": 765,"number": 654,"name": "maths","unit": "vect", },"amount": 5.88...
View Article