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 ...
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"]' | ...
2
Solved
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...
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...
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...
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...
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...
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"
},
{
...
4
Solved
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...
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....
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...
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.
...
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...
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...
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...
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...
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...
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]...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.