jq Questions

6

Solved

I'd like to add leading/trailing zeros to strings from numbers — resultant string needs to contain "01" or "001" and not "1". I noticed project https://github.com/joel...
Drainage asked 22/11, 2020 at 18:36

5

I am trying to merge all json files in a directory (can be many). I know that if there are only 2 files, I can use jq -s . file1.json file2.json. But when I tried to use the a wild card like jq -s ...
Papst asked 23/7, 2020 at 4:38

3

Solved

In jq, I can select an item in a list fairly easily: $ echo '["a","b","c","d","e"]' | jq '.[] | select(. == ("a","c"))' Or if you prefer to get it as an array: $ echo '["a","b","c","d","e"]' | ...
Penney asked 15/6, 2017 at 8:56

2

Solved

My json looks like this : { "20160522201409-jobsv1-1": { "vmStateDisplayName": "Ready", "servers": { "20160522201409 jobs_v1 1": { "serverStateDisplayName": "Ready", "creationDate": "2016-0...
Katelyn asked 1/6, 2016 at 19:56

4

Solved

Given {"a": 1234567890}, I want 1,234,567,890 in the result, how this can be done with jq echo '{"a": 1234567890}' | jq '.a | FORMAT?' Thanks for @peak's answer, the solution is echo '{"a": 12...
Varus asked 10/2, 2020 at 10:29

3

Duplicate of this issue, but the first answer there is wrong (jq is supported on Windows) and the second refers to brew so I'm guessing is for Mac. Windows I am trying to install jq for python fr...
Kalmia asked 16/2, 2017 at 0:59

4

Solved

I have a requirement to tag records uniquely with UUIDs (for a correlation id). I cant see a direct way to do this via the options, is such a thing possible? If not, is there some kind of workaroun...
Achlamydeous asked 16/5, 2020 at 20:10

4

Solved

I get a very large JSON stream (several GB) from curl and try to process it with jq. The relevant output I want to parse with jq is packed in a document representing the result structure: { "res...
Carrell asked 30/8, 2016 at 15:51

3

Solved

I use jq to transform a complex json object into a tinier one. My query is: jq 'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode: (.value.booking_service_code)}' compani...
Anticlockwise asked 20/2, 2018 at 14:38

5

I would like to convert the stream of objects: { "a": "green", "b": "white" } { "a": "red", "c": "purple" } into one object: { "a": "red", "b": "white", "c": "purple" } Also, how can I...
Patriciapatrician asked 27/12, 2015 at 4:24

1

Let's pretend I'm running something like this: jq -nr --arg target /tmp \ '(["echo","Hello, world"]|@sh)+">\($target)/sample.txt"' \ | sh Everything is fine unles...
jq
Fritzie asked 27/11, 2019 at 18:32

3

Solved

There is a json file like this: [ { "createdAt": 1548729542000, "platform": "foo" }, { "createdAt": 1548759398000, "platform": "foo" }, { "createdAt": 1548912360000, "platform": "foo" }, { ...
Offside asked 2/2, 2019 at 3:15

4

Solved

I have a json object with one of field having values for example "countries-sapi-1.0", "inventory-list-api-1.0-snapshot" Note that the first one has sapi and the other one has a...
Sungkiang asked 29/3, 2018 at 8:55

10

If you have a csv dataset like this: name, age, gender john, 20, male jane, 30, female bob, 25, male Can you get to this: [ {"name": "john", "age": 20, "gender&q...
Mack asked 16/4, 2015 at 0:14

2

Solved

I have jq command like this: jq --arg ts "$TS" '.Date = $ts, .Marker.Date = $ts, .InfoFromTerminator.Timestamp = $ts' but it appears to only replace the last item keeping the previous two as is....
Towbin asked 12/10, 2015 at 7:19

1

I have a json file with the following contents: { "id1": { "key": "value" }, "id2": { "key": "value" } } I want to check that each...
Aletheaalethia asked 19/2, 2024 at 14:13

7

Solved

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 lin...
Apraxia asked 1/8, 2018 at 7:55

3

Solved

jq is suppose to process/filter JSON inputs and producing the filter's results as JSON However, I found that after the jq process/filter, output result is no longer in JSON format any more. ...
Sappington asked 17/3, 2018 at 21:32

4

Solved

I want to use jq map my input ["a", "b"] to output [{name: "a", index: 0}, {name: "b", index: 1}] I got as far as 0 as $i | def incr: $i = $i + 1; [.[] | {name:., index:incr}]' which outp...
jq
Paramatta asked 2/7, 2014 at 10:1

4

Solved

I have a list of objects that look like this: [ { "ip": "1.1.1.1", "component": "name1" }, { "ip": "1.1.1.2", "component": "name1" }, { "ip": "1.1.1.3", "component": "name2" }, { "ip...
Plasmolysis asked 5/4, 2017 at 3:46

7

Solved

I'm using jq to parse some of my logs, but some of the log lines can't be parsed for various reasons. Is there a way to have jq ignore those lines? I can't seem to find a solution. I tried to use t...
Antihero asked 11/1, 2017 at 19:37

4

Solved

I have the following JSON file with example values: { "files": [{ "fileName": "FOO", "md5": "blablabla" }, { "fileName": "BAR&q...
Harmon asked 1/6, 2016 at 8:45

2

Solved

how to get multiple values from a JSON array/object using jq in a single line? here curl request and its response curl -s -k --location --request GET "https://${HOSTNAME}/api/v1/projects/myPro...
Leucotomy asked 22/4, 2022 at 5:15

12

I have a JSON data as follows in data.json file [ {"original_name":"pdf_convert","changed_name":"pdf_convert_1"}, {"original_name":"video_encode","changed_name":"video_encode_1"}, {"original_na...
Figural asked 27/11, 2015 at 5:6

7

I'm trying to execute a jq command from my python script. Currently the jq command is working fine when I execute from the terminal (MacOs). cat filename.json |jq '{Name:.name, address:.address[0]...
Hydrokinetic asked 6/7, 2016 at 9:16

© 2022 - 2025 — McMap. All rights reserved.