Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
11
14
request
stringlengths
50
307
command
stringlengths
7
382
input_text
stringlengths
1
2.27k
expected_output
stringlengths
2
964
validation_input
stringlengths
2
1.17k
validation_output
stringlengths
2
758
family
stringclasses
1 value
difficulty
int64
3
3
split
stringclasses
1 value
source
stringclasses
2 values
license
stringclasses
1 value
question_url
stringlengths
60
125
question_title
stringlengths
15
122
question_owner
stringlengths
3
29
answer_owner
stringclasses
58 values
answer_id
int64
18.8M
76.2M
question_score
int64
5
38
reviewed
bool
1 class
paraphrase_of
stringlengths
11
11
⌀
paraphrase_model
stringclasses
1 value
so-23268506
Recursively extract the values associated with the key "updateDate" from a nested JSON structure, ignoring non-object types and avoiding errors.
jq '.. | objects | select(has("updateDate")) | .updateDate'
{"a": {"updateDate": "2023-01-01", "b": [{"updateDate": "2023-02-02"}, "string"]}, "c": 123}
"2023-01-01" "2023-02-02"
{"x": {"y": {"updateDate": "now"}}, "z": [1, {"updateDate": "later"}]}
"now" "later"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/23268506/jq-select-objects-with-given-key-name
jq - select objects with given key name
DisplayName
user2259432
24,300,334
33
true
null
null
so-23268506-p1
Safely traverse a nested JSON structure to recursively collect all values linked to the key "updateDate", skipping non-object types to prevent errors.
jq '.. | objects | select(has("updateDate")) | .updateDate'
{"a": {"updateDate": "2023-01-01", "b": [{"updateDate": "2023-02-02"}, "string"]}, "c": 123}
"2023-01-01" "2023-02-02"
{"x": {"y": {"updateDate": "now"}}, "z": [1, {"updateDate": "later"}]}
"now" "later"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/23268506/jq-select-objects-with-given-key-name
jq - select objects with given key name
DisplayName
user2259432
24,300,334
33
true
so-23268506
qwen/qwen3.7-plus
so-25649960
Filter a stream of JSON objects to include only those where the "items" array contains the string "blue".
jq 'select(.items | index("blue"))'
{"items":["blue","green"]} {"items":["yellow","green"]} {"items":["blue","pink"]}
{ "items": [ "blue", "green" ] } { "items": [ "blue", "pink" ] }
{"items":["red","blue"]} {"items":["green"]} {"items":["blue"]}
{ "items": [ "red", "blue" ] } { "items": [ "blue" ] }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/25649960/how-to-select-items-in-jq-based-on-value-in-array
How to select items in JQ based on value in array
K2xL
K2xL
25,650,468
32
true
null
null
so-25649960-p1
Process a stream of JSON objects and retain only those where the "items" array includes the string "blue".
jq 'select(.items | index("blue"))'
{"items":["blue","green"]} {"items":["yellow","green"]} {"items":["blue","pink"]}
{ "items": [ "blue", "green" ] } { "items": [ "blue", "pink" ] }
{"items":["red","blue"]} {"items":["green"]} {"items":["blue"]}
{ "items": [ "red", "blue" ] } { "items": [ "blue" ] }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/25649960/how-to-select-items-in-jq-based-on-value-in-array
How to select items in JQ based on value in array
K2xL
K2xL
25,650,468
32
true
so-25649960
qwen/qwen3.7-plus
so-27838154
Filter an array of objects to keep only the 'name' key for each object.
jq 'map({name})'
[{"name": "Alice", "group": "Admins", "created": "2014"}, {"name": "Bob", "group": "Users", "created": "2014"}]
[ { "name": "Alice" }, { "name": "Bob" } ]
[{"name": "Charlie", "role": "Dev", "id": 1}, {"name": "Dave", "role": "Ops", "id": 2}]
[ { "name": "Charlie" }, { "name": "Dave" } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/27838154/how-do-i-remove-all-keys-except-one-with-jq
How do I remove all keys except one with jq?
Wilfred Hughes
Girish
27,838,881
33
true
null
null
so-27838154-p1
Map an array of objects to a new array containing only the 'name' property from each original object.
jq 'map({name})'
[{"name": "Alice", "group": "Admins", "created": "2014"}, {"name": "Bob", "group": "Users", "created": "2014"}]
[ { "name": "Alice" }, { "name": "Bob" } ]
[{"name": "Charlie", "role": "Dev", "id": 1}, {"name": "Dave", "role": "Ops", "id": 2}]
[ { "name": "Charlie" }, { "name": "Dave" } ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/27838154/how-do-i-remove-all-keys-except-one-with-jq
How do I remove all keys except one with jq?
Wilfred Hughes
Girish
27,838,881
33
true
so-27838154
qwen/qwen3.7-plus
so-28593471
Recursively unmarshal DynamoDB JSON output by converting typed wrappers (S, N, BOOL, M, L, SS, NS, BS) into their native JSON types.
jq 'def decode: if type == "object" then if has("S") then .S elif has("N") then (.N | tonumber) elif has("BOOL") then .BOOL elif has("M") then (.M | map_values(decode)) elif has("L") then (.L | map(decode)) elif has("SS") then .SS elif has("NS") then (.NS | map(tonumber)) elif has("BS") then .BS else map_values(decode)...
{ "Count": 1, "Items": [ { "Id": { "S": "app1" }, "Parameters": { "M": { "nfs": { "M": { "IP": { "S": "172.16.0.178" }, "activated": { "BOOL": true } } ...
{ "Count": 1, "Items": [ { "Id": "app1", "Parameters": { "nfs": { "IP": "172.16.0.178", "activated": true }, "ws": { "number": 5, "values": [ "12253456346346", "23452353463464" ] } }, ...
{ "Count": 2, "Items": [ { "Id": { "S": "item2" }, "Data": { "M": { "active": { "BOOL": false }, "score": { "N": "100" } } } } ], "ScannedCount": 2 }
{ "Count": 2, "Items": [ { "Id": "item2", "Data": { "active": false, "score": 100 } } ], "ScannedCount": 2 }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/28593471/how-to-simplify-aws-dynamodb-query-json-output-from-the-command-line
How to simplify aws DynamoDB query JSON output from the command line?
herve
Jeff Mercado
28,641,626
32
true
null
null
so-28593471-p1
Convert DynamoDB-formatted JSON into standard native JSON types by recursively unwrapping typed attributes such as S, N, BOOL, M, L, SS, NS, and BS.
jq 'def decode: if type == "object" then if has("S") then .S elif has("N") then (.N | tonumber) elif has("BOOL") then .BOOL elif has("M") then (.M | map_values(decode)) elif has("L") then (.L | map(decode)) elif has("SS") then .SS elif has("NS") then (.NS | map(tonumber)) elif has("BS") then .BS else map_values(decode)...
{ "Count": 1, "Items": [ { "Id": { "S": "app1" }, "Parameters": { "M": { "nfs": { "M": { "IP": { "S": "172.16.0.178" }, "activated": { "BOOL": true } } ...
{ "Count": 1, "Items": [ { "Id": "app1", "Parameters": { "nfs": { "IP": "172.16.0.178", "activated": true }, "ws": { "number": 5, "values": [ "12253456346346", "23452353463464" ] } }, ...
{ "Count": 2, "Items": [ { "Id": { "S": "item2" }, "Data": { "M": { "active": { "BOOL": false }, "score": { "N": "100" } } } } ], "ScannedCount": 2 }
{ "Count": 2, "Items": [ { "Id": "item2", "Data": { "active": false, "score": 100 } } ], "ScannedCount": 2 }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/28593471/how-to-simplify-aws-dynamodb-query-json-output-from-the-command-line
How to simplify aws DynamoDB query JSON output from the command line?
herve
Jeff Mercado
28,641,626
32
true
so-28593471
qwen/qwen3.7-plus
so-28615174
Filter a JSON object to keep only entries where the nested 'Job' field is equal to 'Clown'.
jq 'with_entries(select(.value.Job == "Clown"))'
{"Joe": {"Job": "Clown", "Age": 22}, "Sally": {"Job": "Programmer", "Age": 32}, "Anne": {"Job": "Clown", "Age": 29}}
{ "Joe": { "Job": "Clown", "Age": 22 }, "Anne": { "Job": "Clown", "Age": 29 } }
{"Bob": {"Job": "Clown", "Age": 40}, "Alice": {"Job": "Doctor", "Age": 30}}
{ "Bob": { "Job": "Clown", "Age": 40 } }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/28615174/jq-filter-on-sub-object-value
jq Filter on sub object value
Christopher Helck
Hans Z.
28,617,380
18
true
null
null
so-28615174-p1
Filter a JSON object to retain only the entries where the nested 'Job' field matches the value 'Clown'.
jq 'with_entries(select(.value.Job == "Clown"))'
{"Joe": {"Job": "Clown", "Age": 22}, "Sally": {"Job": "Programmer", "Age": 32}, "Anne": {"Job": "Clown", "Age": 29}}
{ "Joe": { "Job": "Clown", "Age": 22 }, "Anne": { "Job": "Clown", "Age": 29 } }
{"Bob": {"Job": "Clown", "Age": 40}, "Alice": {"Job": "Doctor", "Age": 30}}
{ "Bob": { "Job": "Clown", "Age": 40 } }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/28615174/jq-filter-on-sub-object-value
jq Filter on sub object value
Christopher Helck
Hans Z.
28,617,380
18
true
so-28615174
qwen/qwen3.7-plus
so-29389010
From the 'devices' object, select only the entries where the key starts with 'dimmer', and create a new object containing those keys mapped to their 'state' value.
jq '[ .devices | to_entries[] | select(.key | startswith("dimmer")) | {key: .key, value: .value.state} ] | from_entries'
{ "devices": { "dimmer1": { "protocol": ["kaku_dimmer"], "state": "off", "dimlevel": 1 }, "dimmer2": { "protocol": ["kaku_dimmer"], "state": "on", "dimlevel": 5 }, "switch1": { "protocol": ["kaku_switch"], "state": "off" } } }
{ "dimmer1": "off", "dimmer2": "on" }
{ "devices": { "dimmerA": { "protocol": ["proto_a"], "state": "on", "dimlevel": 10 }, "lightB": { "protocol": ["proto_b"], "state": "off" }, "dimmerC": { "protocol": ["proto_c"], "state": "off", "dimlevel": 0 } } }
{ "dimmerA": "on", "dimmerC": "off" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/29389010/jq-parsing-get-value
jq parsing get value
user3467696
Wintermute
29,389,469
32
true
null
null
so-29389010-p1
From the 'devices' object, filter keys starting with 'dimmer' and construct a new object mapping these keys to their corresponding 'state' values.
jq '[ .devices | to_entries[] | select(.key | startswith("dimmer")) | {key: .key, value: .value.state} ] | from_entries'
{ "devices": { "dimmer1": { "protocol": ["kaku_dimmer"], "state": "off", "dimlevel": 1 }, "dimmer2": { "protocol": ["kaku_dimmer"], "state": "on", "dimlevel": 5 }, "switch1": { "protocol": ["kaku_switch"], "state": "off" } } }
{ "dimmer1": "off", "dimmer2": "on" }
{ "devices": { "dimmerA": { "protocol": ["proto_a"], "state": "on", "dimlevel": 10 }, "lightB": { "protocol": ["proto_b"], "state": "off" }, "dimmerC": { "protocol": ["proto_c"], "state": "off", "dimlevel": 0 } } }
{ "dimmerA": "on", "dimmerC": "off" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/29389010/jq-parsing-get-value
jq parsing get value
user3467696
Wintermute
29,389,469
32
true
so-29389010
qwen/qwen3.7-plus
so-29772676
Update the 'format' field to 'csv' for the object in the array where the 'id' is 'baz'.
jq '(.. | objects | select(.id == "baz") | .format) |= "csv"'
[ { "format": "geojson", "id": "foo" }, { "format": "geojson", "id": "bar" }, { "format": "zip", "id": "baz" } ]
[ { "format": "geojson", "id": "foo" }, { "format": "geojson", "id": "bar" }, { "format": "csv", "id": "baz" } ]
[ { "format": "xml", "id": "alpha" }, { "format": "json", "id": "beta" }, { "format": "yaml", "id": "baz" }, { "format": "txt", "id": "gamma" } ]
[ { "format": "xml", "id": "alpha" }, { "format": "json", "id": "beta" }, { "format": "csv", "id": "baz" }, { "format": "txt", "id": "gamma" } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/29772676/update-one-value-in-array-of-dicts-using-jq
Update one value in array of dicts, using jq
Steve Bennett
Hans Z.
29,773,197
32
true
null
null
so-29772676-p1
Locate the object with 'id' equal to 'baz' within an array and update its 'format' field to 'csv'.
jq '(.. | objects | select(.id == "baz") | .format) |= "csv"'
[ { "format": "geojson", "id": "foo" }, { "format": "geojson", "id": "bar" }, { "format": "zip", "id": "baz" } ]
[ { "format": "geojson", "id": "foo" }, { "format": "geojson", "id": "bar" }, { "format": "csv", "id": "baz" } ]
[ { "format": "xml", "id": "alpha" }, { "format": "json", "id": "beta" }, { "format": "yaml", "id": "baz" }, { "format": "txt", "id": "gamma" } ]
[ { "format": "xml", "id": "alpha" }, { "format": "json", "id": "beta" }, { "format": "csv", "id": "baz" }, { "format": "txt", "id": "gamma" } ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/29772676/update-one-value-in-array-of-dicts-using-jq
Update one value in array of dicts, using jq
Steve Bennett
Hans Z.
29,773,197
32
true
so-29772676
qwen/qwen3.7-plus
so-29982897
For each object in the 'snapshots' array, output a single line containing the 'end_time_in_millis' and 'snapshot' values separated by a space.
jq -r '.snapshots[] | "\(.end_time_in_millis) \(.snapshot)"'
{"snapshots": [{"shards": {"successful": 1, "failed": 0, "total": 1}, "failures": [], "snapshot": "snapshot_1", "indices": ["myindex1"], "state": "SUCCESS", "start_time": "2015-04-21T09:45:47.041Z", "start_time_in_millis": 1429609547041, "end_time": "2015-04-21T09:49:50.767Z", "end_time_in_millis": 1429609790767, "dura...
1429609790767 snapshot_1 1429681169896 snapshot_2
{"snapshots": [{"shards": {"successful": 2, "failed": 0, "total": 2}, "failures": [], "snapshot": "snap_A", "indices": ["idx1"], "state": "SUCCESS", "start_time": "2020-01-01T00:00:00.000Z", "start_time_in_millis": 1000000000000, "end_time": "2020-01-01T00:01:00.000Z", "end_time_in_millis": 1000000060000, "duration_in_...
1000000060000 snap_A
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/29982897/using-jq-to-extract-specific-property-values-and-output-on-a-single-line
Using jq to extract specific property values and output on a single line
mark
Jeff Mercado
29,982,986
19
true
null
null
so-29982897-p1
Iterate through the 'snapshots' array and print each 'end_time_in_millis' and 'snapshot' value on a single line, separated by a space.
jq -r '.snapshots[] | "\(.end_time_in_millis) \(.snapshot)"'
{"snapshots": [{"shards": {"successful": 1, "failed": 0, "total": 1}, "failures": [], "snapshot": "snapshot_1", "indices": ["myindex1"], "state": "SUCCESS", "start_time": "2015-04-21T09:45:47.041Z", "start_time_in_millis": 1429609547041, "end_time": "2015-04-21T09:49:50.767Z", "end_time_in_millis": 1429609790767, "dura...
1429609790767 snapshot_1 1429681169896 snapshot_2
{"snapshots": [{"shards": {"successful": 2, "failed": 0, "total": 2}, "failures": [], "snapshot": "snap_A", "indices": ["idx1"], "state": "SUCCESS", "start_time": "2020-01-01T00:00:00.000Z", "start_time_in_millis": 1000000000000, "end_time": "2020-01-01T00:01:00.000Z", "end_time_in_millis": 1000000060000, "duration_in_...
1000000060000 snap_A
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/29982897/using-jq-to-extract-specific-property-values-and-output-on-a-single-line
Using jq to extract specific property values and output on a single line
mark
Jeff Mercado
29,982,986
19
true
so-29982897
qwen/qwen3.7-plus
so-30015555
Transform the input JSON array of commit objects into CSV format, including a header row with the keys 'message' and 'name'. Extract 'message' from '.commit.message' and 'name' from '.commit.committer.name'.
jq -r 'map({message: .commit.message, name: .commit.committer.name}) | (.[0] | to_entries | map(.key)), (.[] | [.[]]) | @csv'
[{"commit": {"message": "Fix README", "committer": {"name": "Nicolas Williams"}}}, {"commit": {"message": "Update docs", "committer": {"name": "John Doe"}}}]
"message","name" "Fix README","Nicolas Williams" "Update docs","John Doe"
[{"commit": {"message": "Initial commit", "committer": {"name": "Alice"}}}, {"commit": {"message": "Bug fix", "committer": {"name": "Bob"}}}]
"message","name" "Initial commit","Alice" "Bug fix","Bob"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/30015555/how-to-add-a-header-to-csv-export-in-jq
How to add a header to CSV export in jq?
Anton Tarasenko
user3899165
30,032,247
35
true
null
null
so-30015555-p1
Convert a JSON array of commit objects into CSV format with a header row for 'message' and 'name', extracting data from '.commit.message' and '.commit.committer.name' respectively.
jq -r 'map({message: .commit.message, name: .commit.committer.name}) | (.[0] | to_entries | map(.key)), (.[] | [.[]]) | @csv'
[{"commit": {"message": "Fix README", "committer": {"name": "Nicolas Williams"}}}, {"commit": {"message": "Update docs", "committer": {"name": "John Doe"}}}]
"message","name" "Fix README","Nicolas Williams" "Update docs","John Doe"
[{"commit": {"message": "Initial commit", "committer": {"name": "Alice"}}}, {"commit": {"message": "Bug fix", "committer": {"name": "Bob"}}}]
"message","name" "Initial commit","Alice" "Bug fix","Bob"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/30015555/how-to-add-a-header-to-csv-export-in-jq
How to add a header to CSV export in jq?
Anton Tarasenko
user3899165
30,032,247
35
true
so-30015555
qwen/qwen3.7-plus
so-30601278
Extract OwnerId, InstanceId, ImageId, PrivateIpAddress, and Platform from nested Reservations and Instances arrays into a flat object for each instance.
jq '.Reservations[] | .OwnerId as $OwnerId | (.Instances[] | { "OwnerId": $OwnerId, InstanceId, ImageId, PrivateIpAddress, Platform})'
{"Reservations": [{"OwnerId": "000000000000", "ReservationId": "r-22222222", "Groups": [], "RequesterId": "111111111111", "Instances": [{"Monitoring": {"State": "enabled"}, "PublicDnsName": null, "State": {"Code": 16, "Name": "running"}, "EbsOptimized": false, "LaunchTime": "2015-04-10T00:02:02.000Z", "Platform": "wind...
{ "OwnerId": "000000000000", "InstanceId": "i-v33333333", "ImageId": "ami-44444444", "PrivateIpAddress": "10.0.0.0", "Platform": "windows" }
{"Reservations": [{"OwnerId": "111111111111", "ReservationId": "r-33333333", "Groups": [], "RequesterId": "222222222222", "Instances": [{"Monitoring": {"State": "disabled"}, "PublicDnsName": "ec2-1-2-3-4.compute.amazonaws.com", "State": {"Code": 80, "Name": "stopped"}, "EbsOptimized": true, "LaunchTime": "2016-05-11T01...
{ "OwnerId": "111111111111", "InstanceId": "i-a11111111", "ImageId": "ami-55555555", "PrivateIpAddress": "192.168.1.1", "Platform": "linux" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/30601278/how-to-extract-keys-from-multiple-nested-arrays-using-jq
How to extract keys from multiple, nested arrays using jq
Paul Ericson
Hans Z.
30,602,908
19
true
null
null
so-30601278-p1
Flatten nested Reservations and Instances arrays into individual objects, extracting OwnerId, InstanceId, ImageId, PrivateIpAddress, and Platform for each instance.
jq '.Reservations[] | .OwnerId as $OwnerId | (.Instances[] | { "OwnerId": $OwnerId, InstanceId, ImageId, PrivateIpAddress, Platform})'
{"Reservations": [{"OwnerId": "000000000000", "ReservationId": "r-22222222", "Groups": [], "RequesterId": "111111111111", "Instances": [{"Monitoring": {"State": "enabled"}, "PublicDnsName": null, "State": {"Code": 16, "Name": "running"}, "EbsOptimized": false, "LaunchTime": "2015-04-10T00:02:02.000Z", "Platform": "wind...
{ "OwnerId": "000000000000", "InstanceId": "i-v33333333", "ImageId": "ami-44444444", "PrivateIpAddress": "10.0.0.0", "Platform": "windows" }
{"Reservations": [{"OwnerId": "111111111111", "ReservationId": "r-33333333", "Groups": [], "RequesterId": "222222222222", "Instances": [{"Monitoring": {"State": "disabled"}, "PublicDnsName": "ec2-1-2-3-4.compute.amazonaws.com", "State": {"Code": 80, "Name": "stopped"}, "EbsOptimized": true, "LaunchTime": "2016-05-11T01...
{ "OwnerId": "111111111111", "InstanceId": "i-a11111111", "ImageId": "ami-55555555", "PrivateIpAddress": "192.168.1.1", "Platform": "linux" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/30601278/how-to-extract-keys-from-multiple-nested-arrays-using-jq
How to extract keys from multiple, nested arrays using jq
Paul Ericson
Hans Z.
30,602,908
19
true
so-30601278
qwen/qwen3.7-plus
so-33627427
Given a JSON object with a top-level key "p" containing nested objects, produce an object where the keys are the immediate children of "p" and the values are arrays of the keys of those children.
jq '.p | map_values(keys)'
{"p": {"d": {"a": {"r": "foo"}, "b": {"r": "bar"}}, "c": {"e": {"r": "baz"}}}}
{ "d": [ "a", "b" ], "c": [ "e" ] }
{"p": {"group1": {"item1": {}, "item2": {}}, "group2": {"item3": {}}}}
{ "group1": [ "item1", "item2" ], "group2": [ "item3" ] }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/33627427/jq-getting-two-levels-of-keys
jq: Getting two levels of keys
Henrik supports the community
user3899165
33,630,944
33
true
null
null
so-33627427-p1
Generate an object from a JSON input where the top-level key is "p"; the output keys should be the immediate children of "p", and the values should be arrays of the keys belonging to those children.
jq '.p | map_values(keys)'
{"p": {"d": {"a": {"r": "foo"}, "b": {"r": "bar"}}, "c": {"e": {"r": "baz"}}}}
{ "d": [ "a", "b" ], "c": [ "e" ] }
{"p": {"group1": {"item1": {}, "item2": {}}, "group2": {"item3": {}}}}
{ "group1": [ "item1", "item2" ], "group2": [ "item3" ] }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/33627427/jq-getting-two-levels-of-keys
jq: Getting two levels of keys
Henrik supports the community
user3899165
33,630,944
33
true
so-33627427
qwen/qwen3.7-plus
so-35540294
Sort the input JSON array of objects first by 'prop1' in descending order, and then by 'prop2' in ascending order.
jq 'sort_by(-.prop1, .prop2)'
[{"name": "Object 1", "prop1": 5, "prop2": 2}, {"name": "Object 2", "prop1": 6, "prop2": 4}, {"name": "Object 3", "prop1": 5, "prop2": 3}]
[ { "name": "Object 2", "prop1": 6, "prop2": 4 }, { "name": "Object 1", "prop1": 5, "prop2": 2 }, { "name": "Object 3", "prop1": 5, "prop2": 3 } ]
[{"name": "A", "prop1": 10, "prop2": 1}, {"name": "B", "prop1": 10, "prop2": 2}, {"name": "C", "prop1": 5, "prop2": 1}]
[ { "name": "A", "prop1": 10, "prop2": 1 }, { "name": "B", "prop1": 10, "prop2": 2 }, { "name": "C", "prop1": 5, "prop2": 1 } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/35540294/sort-descending-by-multiple-keys-in-jq
Sort descending by multiple keys in jq
Roland Weisleder
user3899165
35,541,425
36
true
null
null
so-35540294-p1
Sort an array of JSON objects primarily by 'prop1' in descending order, using 'prop2' in ascending order as the secondary sort criterion.
jq 'sort_by(-.prop1, .prop2)'
[{"name": "Object 1", "prop1": 5, "prop2": 2}, {"name": "Object 2", "prop1": 6, "prop2": 4}, {"name": "Object 3", "prop1": 5, "prop2": 3}]
[ { "name": "Object 2", "prop1": 6, "prop2": 4 }, { "name": "Object 1", "prop1": 5, "prop2": 2 }, { "name": "Object 3", "prop1": 5, "prop2": 3 } ]
[{"name": "A", "prop1": 10, "prop2": 1}, {"name": "B", "prop1": 10, "prop2": 2}, {"name": "C", "prop1": 5, "prop2": 1}]
[ { "name": "A", "prop1": 10, "prop2": 1 }, { "name": "B", "prop1": 10, "prop2": 2 }, { "name": "C", "prop1": 5, "prop2": 1 } ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/35540294/sort-descending-by-multiple-keys-in-jq
Sort descending by multiple keys in jq
Roland Weisleder
user3899165
35,541,425
36
true
so-35540294
qwen/qwen3.7-plus
so-37540717
Flatten a nested JSON object into a single-level object where keys are dot-separated paths to leaf values.
jq '[paths(scalars) as $path | {"key": $path | join("."), "value": getpath($path)}] | from_entries'
{"a":{"b":1}}
{ "a.b": 1 }
{"x":{"y":{"z":2},"w":3}}
{ "x.y.z": 2, "x.w": 3 }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/37540717/flatten-nested-json-using-jq
Flatten nested JSON using jq
assafmo
user3899165
37,555,908
20
true
null
null
so-37540717-p1
Convert a nested JSON structure into a flat object, using dot notation for keys that represent the path to each leaf value.
jq '[paths(scalars) as $path | {"key": $path | join("."), "value": getpath($path)}] | from_entries'
{"a":{"b":1}}
{ "a.b": 1 }
{"x":{"y":{"z":2},"w":3}}
{ "x.y.z": 2, "x.w": 3 }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/37540717/flatten-nested-json-using-jq
Flatten nested JSON using jq
assafmo
user3899165
37,555,908
20
true
so-37540717
qwen/qwen3.7-plus
so-38186594
Select objects from an array where the test field is strictly boolean false.
jq '.[] | select(.test == false)'
[{"id": 1, "test": true}, {"id": 2, "test": false}, {"id": 3, "test": "false"}]
{ "id": 2, "test": false }
[{"name": "a", "test": false}, {"name": "b", "test": true}, {"name": "c", "test": null}]
{ "name": "a", "test": false }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/38186594/jq-how-to-select-objects-where-a-field-is-false
jq - How to select objects where a field is 'false'?
x3nr0s
peak
38,187,498
19
true
null
null
so-38186594-p1
Filter an array to include only those objects where the 'test' property is strictly the boolean value false.
jq '.[] | select(.test == false)'
[{"id": 1, "test": true}, {"id": 2, "test": false}, {"id": 3, "test": "false"}]
{ "id": 2, "test": false }
[{"name": "a", "test": false}, {"name": "b", "test": true}, {"name": "c", "test": null}]
{ "name": "a", "test": false }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/38186594/jq-how-to-select-objects-where-a-field-is-false
jq - How to select objects where a field is 'false'?
x3nr0s
peak
38,187,498
19
true
so-38186594
qwen/qwen3.7-plus
so-38459429
Recursively search a JSON object for all non-null values associated with the key 'error'.
jq '.. | .error? // empty'
{ "A": { "error": null }, "B": { "C": {"error": "error string"}}, "C": { "D": {"error": null}}, "D": { "error": "err str"} }
"error string" "err str"
{ "X": { "error": "fail" }, "Y": { "Z": {"error": null}}, "W": { "error": "oops"} }
"fail" "oops"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/38459429/recursive-search-values-by-key
Recursive search values by key
Ardling
user3899165
38,460,947
20
true
null
null
so-38459429-p1
Perform a recursive search on a JSON object to retrieve all non-null values linked to the key 'error'.
jq '.. | .error? // empty'
{ "A": { "error": null }, "B": { "C": {"error": "error string"}}, "C": { "D": {"error": null}}, "D": { "error": "err str"} }
"error string" "err str"
{ "X": { "error": "fail" }, "Y": { "Z": {"error": null}}, "W": { "error": "oops"} }
"fail" "oops"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/38459429/recursive-search-values-by-key
Recursive search values by key
Ardling
user3899165
38,460,947
20
true
so-38459429
qwen/qwen3.7-plus
so-38626762
Remove the "source" key from all objects nested directly under the "b" key in the input JSON object.
jq '.b[] |= del(.source)'
{"a":1,"b":{"c":{"c1":"abc","source":"abcxyz"},"d":{"d1":"abcd","source":"abcxyz"}}}
{ "a": 1, "b": { "c": { "c1": "abc" }, "d": { "d1": "abcd" } } }
{"a":1,"b":{"x":{"x1":"val","source":"src"},"y":{"y1":"val2","source":"src2"}}}
{ "a": 1, "b": { "x": { "x1": "val" }, "y": { "y1": "val2" } } }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/38626762/jq-delete-multiple-properties
JQ delete multiple properties
Vu Le Anh
user3899165
38,657,597
24
true
null
null
so-38626762-p1
Delete the 'source' property from every object that is a direct child of the 'b' key in the input JSON.
jq '.b[] |= del(.source)'
{"a":1,"b":{"c":{"c1":"abc","source":"abcxyz"},"d":{"d1":"abcd","source":"abcxyz"}}}
{ "a": 1, "b": { "c": { "c1": "abc" }, "d": { "d1": "abcd" } } }
{"a":1,"b":{"x":{"x1":"val","source":"src"},"y":{"y1":"val2","source":"src2"}}}
{ "a": 1, "b": { "x": { "x1": "val" }, "y": { "y1": "val2" } } }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/38626762/jq-delete-multiple-properties
JQ delete multiple properties
Vu Le Anh
user3899165
38,657,597
24
true
so-38626762
qwen/qwen3.7-plus
so-39500608
Remove all keys with null values from a JSON object.
jq 'with_entries(select(.value != null))'
{"a": 1, "b": null, "c": 2, "d": null}
{ "a": 1, "c": 2 }
{"x": null, "y": "hello", "z": null}
{ "y": "hello" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/39500608/remove-all-null-values
Remove all null values
Ela
peak
39,501,001
33
true
null
null
so-39500608-p1
Strip all keys holding null values from a JSON object.
jq 'with_entries(select(.value != null))'
{"a": 1, "b": null, "c": 2, "d": null}
{ "a": 1, "c": 2 }
{"x": null, "y": "hello", "z": null}
{ "y": "hello" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/39500608/remove-all-null-values
Remove all null values
Ela
peak
39,501,001
33
true
so-39500608
qwen/qwen3.7-plus
so-39800718
Find all paths in a nested JSON object that end with the key 'foo'.
jq -c 'paths | select(.[-1] == "foo")'
{ "A": { "A1": { "foo": { "_": "_" } }, "A2": { "_": "_" } }, "B": { "B1": {} }, "foo": { "_": "_" } }
["A","A1","foo"] ["foo"]
{ "X": { "Y": { "foo": "bar" } }, "Z": { "foo": { "nested": true } }, "other": "value" }
["X","Y","foo"] ["Z","foo"]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/39800718/how-to-use-jq-to-find-all-paths-to-a-certain-key
How to use jq to find all paths to a certain key
chrisst
peak
39,801,036
27
true
null
null
so-39800718-p1
Identify every path within a nested JSON object that terminates with the key 'foo'.
jq -c 'paths | select(.[-1] == "foo")'
{ "A": { "A1": { "foo": { "_": "_" } }, "A2": { "_": "_" } }, "B": { "B1": {} }, "foo": { "_": "_" } }
["A","A1","foo"] ["foo"]
{ "X": { "Y": { "foo": "bar" } }, "Z": { "foo": { "nested": true } }, "other": "value" }
["X","Y","foo"] ["Z","foo"]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/39800718/how-to-use-jq-to-find-all-paths-to-a-certain-key
How to use jq to find all paths to a certain key
chrisst
peak
39,801,036
27
true
so-39800718
qwen/qwen3.7-plus
so-40321035
Extract the message field from the content object and remove all newline and tab characters from it.
jq -r '.content.message | gsub("[\n\t]"; "")'
{"HOSTNAME":"server1.example","level":"WARN","level_value":30000,"logger_name":"server1.example.adapter","content":{"message":"ERROR LALALLA\nERROR INFO NANANAN\tSOME MORE ERROR INFO\nBABABABABABBA\n BABABABA\t ABABBABAA\n\n BABABABAB\n\n"}}
ERROR LALALLAERROR INFO NANANANSOME MORE ERROR INFOBABABABABABBA BABABABA ABABBABAA BABABABAB
{"HOSTNAME":"server2.example","level":"INFO","level_value":20000,"logger_name":"server2.example.app","content":{"message":"Start\tProcess\nEnd\n"}}
StartProcessEnd
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/40321035/remove-escape-sequence-characters-like-newline-tab-and-carriage-return-from-jso
Remove escape sequence characters like newline, tab and carriage return from JSON file
user3792699
mklement0
40,322,380
19
true
null
null
so-40321035-p1
Retrieve the 'message' field from the 'content' object and strip out all newline and tab characters.
jq -r '.content.message | gsub("[\n\t]"; "")'
{"HOSTNAME":"server1.example","level":"WARN","level_value":30000,"logger_name":"server1.example.adapter","content":{"message":"ERROR LALALLA\nERROR INFO NANANAN\tSOME MORE ERROR INFO\nBABABABABABBA\n BABABABA\t ABABBABAA\n\n BABABABAB\n\n"}}
ERROR LALALLAERROR INFO NANANANSOME MORE ERROR INFOBABABABABABBA BABABABA ABABBABAA BABABABAB
{"HOSTNAME":"server2.example","level":"INFO","level_value":20000,"logger_name":"server2.example.app","content":{"message":"Start\tProcess\nEnd\n"}}
StartProcessEnd
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/40321035/remove-escape-sequence-characters-like-newline-tab-and-carriage-return-from-jso
Remove escape sequence characters like newline, tab and carriage return from JSON file
user3792699
mklement0
40,322,380
19
true
so-40321035
qwen/qwen3.7-plus
so-40847936
Swap the keys and values of a JSON object so that original values become keys and original keys become values.
jq 'to_entries | map({(.value): .key}) | add'
{"123": "Foobar", "567": "Poit"}
{ "Foobar": "123", "Poit": "567" }
{"abc": "xyz", "def": "uvw"}
{ "xyz": "abc", "uvw": "def" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/40847936/how-to-swap-key-and-value-of-an-object-using-jq
How to swap key and value of an object using jq?
k0pernikus
peak
40,849,180
18
true
null
null
so-40847936-p1
Invert a JSON object by swapping its keys and values, making the original values the new keys and vice versa.
jq 'to_entries | map({(.value): .key}) | add'
{"123": "Foobar", "567": "Poit"}
{ "Foobar": "123", "Poit": "567" }
{"abc": "xyz", "def": "uvw"}
{ "xyz": "abc", "uvw": "def" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/40847936/how-to-swap-key-and-value-of-an-object-using-jq
How to swap key and value of an object using jq?
k0pernikus
peak
40,849,180
18
true
so-40847936
qwen/qwen3.7-plus
so-40923539
From an object containing an 'activities' field, filter to keep only entries that have a 'stop_time_utc' key, and return an array of their keys.
jq '.activities | with_entries(select(.value | has("stop_time_utc"))) | keys'
{"activities": {"-KSndgjqvmQkWVKHCpLh": {"create_device": "...", "stop_time_utc": "2016-11-01T23:08:08Z"}, "-KSoBSrBh6PZcjRocGD7": {"create_device": "..."}, "-KSptboGjo8g4bieUbGM": {"create_device": "...", "stop_time_utc": "2017-01-17T23:08:08Z"}}}
[ "-KSndgjqvmQkWVKHCpLh", "-KSptboGjo8g4bieUbGM" ]
{"activities": {"act1": {"status": "active"}, "act2": {"status": "done", "stop_time_utc": "2023-01-01T00:00:00Z"}, "act3": {"status": "pending", "stop_time_utc": "2023-02-01T00:00:00Z"}}}
[ "act2", "act3" ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/40923539/jq-filtering-for-keys
JQ: Filtering for keys
DThimsen
peak
40,924,154
22
true
null
null
so-40923539-p1
From an object with an 'activities' field, filter for entries containing a 'stop_time_utc' key and return an array of their keys.
jq '.activities | with_entries(select(.value | has("stop_time_utc"))) | keys'
{"activities": {"-KSndgjqvmQkWVKHCpLh": {"create_device": "...", "stop_time_utc": "2016-11-01T23:08:08Z"}, "-KSoBSrBh6PZcjRocGD7": {"create_device": "..."}, "-KSptboGjo8g4bieUbGM": {"create_device": "...", "stop_time_utc": "2017-01-17T23:08:08Z"}}}
[ "-KSndgjqvmQkWVKHCpLh", "-KSptboGjo8g4bieUbGM" ]
{"activities": {"act1": {"status": "active"}, "act2": {"status": "done", "stop_time_utc": "2023-01-01T00:00:00Z"}, "act3": {"status": "pending", "stop_time_utc": "2023-02-01T00:00:00Z"}}}
[ "act2", "act3" ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/40923539/jq-filtering-for-keys
JQ: Filtering for keys
DThimsen
peak
40,924,154
22
true
so-40923539
qwen/qwen3.7-plus
so-41712363
Extract the value associated with the key "storage_server.disk_total" from the "stats" object in the provided JSON.
jq '.stats["storage_server.disk_total"]'
{ "stats": { "storage_server.disk_total": 50000000000 }, "counters": {} }
50000000000
{ "stats": { "storage_server.disk_total": 123456789 }, "counters": { "read": 100 } }
123456789
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/41712363/basic-jq-usage-how-to-get-nested-value
Basic jq usage. How to get nested value
nullUser
peak
41,713,087
30
true
null
null
so-41712363-p1
Retrieve the value for the key 'storage_server.disk_total' located within the 'stats' object of the given JSON.
jq '.stats["storage_server.disk_total"]'
{ "stats": { "storage_server.disk_total": 50000000000 }, "counters": {} }
50000000000
{ "stats": { "storage_server.disk_total": 123456789 }, "counters": { "read": 100 } }
123456789
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/41712363/basic-jq-usage-how-to-get-nested-value
Basic jq usage. How to get nested value
nullUser
peak
41,713,087
30
true
so-41712363
qwen/qwen3.7-plus
so-41958475
Given a JSON array of objects, each containing a "name" field, find the zero-based index of the first object where the "name" is equal to "something". If no such object exists, return null.
jq 'map(.name == "something") | index(true)'
[ {"name": "1", "urgent": false}, {"name": "2", "urgent": false}, {"name": "something", "urgent": false} ]
2
[ {"name": "alpha", "urgent": true}, {"name": "beta", "urgent": false}, {"name": "gamma", "urgent": false} ]
null
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/41958475/getting-the-object-array-index-in-jq
Getting the object array index in jq
xeor
JimD.
41,958,933
31
true
null
null
so-41958475-p1
Search a JSON array of objects for the first item where the 'name' field equals 'something' and return its zero-based index, or null if not found.
jq 'map(.name == "something") | index(true)'
[ {"name": "1", "urgent": false}, {"name": "2", "urgent": false}, {"name": "something", "urgent": false} ]
2
[ {"name": "alpha", "urgent": true}, {"name": "beta", "urgent": false}, {"name": "gamma", "urgent": false} ]
null
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/41958475/getting-the-object-array-index-in-jq
Getting the object array index in jq
xeor
JimD.
41,958,933
31
true
so-41958475
qwen/qwen3.7-plus
so-43842672
Extract the value of the 'CloudSanityPassed' field from the 'properties' object in the provided JSON.
jq '.properties.CloudSanityPassed'
{ "properties": { "CloudSanityPassed": ["true"], "GITCOMMIT": ["test1"], "buildNumber": ["54"], "jobName": ["InveergDB-UI"] }, "uri": "http://example.com/file.zip" }
[ "true" ]
{ "properties": { "CloudSanityPassed": ["false"], "GITCOMMIT": ["abc"], "buildNumber": ["99"], "jobName": ["TestJob"] }, "uri": "http://example.com/other.zip" }
[ "false" ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/43842672/jq-cannot-index-string-with-string
jq - Cannot index string with string
dice2011
ymonad
43,842,886
32
true
null
null
so-43842672-p1
Obtain the value of the 'CloudSanityPassed' property from the 'properties' object in the supplied JSON.
jq '.properties.CloudSanityPassed'
{ "properties": { "CloudSanityPassed": ["true"], "GITCOMMIT": ["test1"], "buildNumber": ["54"], "jobName": ["InveergDB-UI"] }, "uri": "http://example.com/file.zip" }
[ "true" ]
{ "properties": { "CloudSanityPassed": ["false"], "GITCOMMIT": ["abc"], "buildNumber": ["99"], "jobName": ["TestJob"] }, "uri": "http://example.com/other.zip" }
[ "false" ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/43842672/jq-cannot-index-string-with-string
jq - Cannot index string with string
dice2011
ymonad
43,842,886
32
true
so-43842672
qwen/qwen3.7-plus
so-44288635
Remove empty strings from a JSON array of strings.
jq 'map(select(length > 0))'
["bob", "", "tim", ""] ["", "alice", "", "charlie", ""]
[ "bob", "tim" ] [ "alice", "charlie" ]
[ ["bob", "tim"], ["alice", "charlie"] ]
[ [ "bob", "tim" ], [ "alice", "charlie" ] ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/44288635/remove-blank-strings-from-array-with-jq
Remove blank strings from array with jq?
leeand00
user197693
44,289,083
21
true
null
null
so-44288635-p1
Filter out empty strings from a JSON string array.
jq 'map(select(length > 0))'
["bob", "", "tim", ""] ["", "alice", "", "charlie", ""]
[ "bob", "tim" ] [ "alice", "charlie" ]
[ ["bob", "tim"], ["alice", "charlie"] ]
[ [ "bob", "tim" ], [ "alice", "charlie" ] ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/44288635/remove-blank-strings-from-array-with-jq
Remove blank strings from array with jq?
leeand00
user197693
44,289,083
21
true
so-44288635
qwen/qwen3.7-plus
so-44704404
Select JSON objects from a stream where the 'author' field matches any value in a specified whitelist array.
jq -s '[.[] | select(.author as $a | ["Gary", "Larry"] | index($a))]'
{"author": "Gary", "text": "Blah"} {"author": "Larry", "text": "More Blah"} {"author": "Jerry", "text": "Yet more Blah"}
[ { "author": "Gary", "text": "Blah" }, { "author": "Larry", "text": "More Blah" } ]
{"author": "Barry", "text": "Even more Blah"} {"author": "Teri", "text": "Text on text on text"} {"author": "Bob", "text": "Another thing to say"}
[]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/44704404/select-entries-based-on-multiple-values-in-jq
Select entries based on multiple values in jq
DGaff
peak
44,707,560
20
true
null
null
so-44704404-p1
From a JSON stream, select objects whose 'author' field matches any entry in a given whitelist array.
jq -s '[.[] | select(.author as $a | ["Gary", "Larry"] | index($a))]'
{"author": "Gary", "text": "Blah"} {"author": "Larry", "text": "More Blah"} {"author": "Jerry", "text": "Yet more Blah"}
[ { "author": "Gary", "text": "Blah" }, { "author": "Larry", "text": "More Blah" } ]
{"author": "Barry", "text": "Even more Blah"} {"author": "Teri", "text": "Text on text on text"} {"author": "Bob", "text": "Another thing to say"}
[]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/44704404/select-entries-based-on-multiple-values-in-jq
Select entries based on multiple values in jq
DGaff
peak
44,707,560
20
true
so-44704404
qwen/qwen3.7-plus
so-45170897
Count the occurrences of each ItmId found in the Properties object of a JSON stream and output an object mapping each ItmId to its count.
jq -s '[.[] | .Properties.ItmId] | group_by(.) | map({(.[0]): length}) | add'
{"ReferringUrl": "N", "OpenAccess": "0", "Properties": {"ItmId": "1694738780"}} {"ReferringUrl": "L", "OpenAccess": "1", "Properties": {"ItmId": "1347809133"}} {"ReferringUrl": "M", "OpenAccess": "0", "Properties": {"ItmId": "1694738780"}}
{ "1347809133": 1, "1694738780": 2 }
{"ReferringUrl": "A", "OpenAccess": "1", "Properties": {"ItmId": "111"}} {"ReferringUrl": "B", "OpenAccess": "0", "Properties": {"ItmId": "222"}} {"ReferringUrl": "C", "OpenAccess": "1", "Properties": {"ItmId": "111"}} {"ReferringUrl": "D", "OpenAccess": "0", "Properties": {"ItmId": "333"}}
{ "111": 2, "222": 1, "333": 1 }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/45170897/jq-count-the-number-of-items-in-json-by-a-specific-key
jq count the number of items in json by a specific key
Eleanor
peak
45,171,347
35
true
null
null
so-45170897-p1
Tally the frequency of each ItmId within the Properties object of a JSON stream and return a mapping of ItmId to count.
jq -s '[.[] | .Properties.ItmId] | group_by(.) | map({(.[0]): length}) | add'
{"ReferringUrl": "N", "OpenAccess": "0", "Properties": {"ItmId": "1694738780"}} {"ReferringUrl": "L", "OpenAccess": "1", "Properties": {"ItmId": "1347809133"}} {"ReferringUrl": "M", "OpenAccess": "0", "Properties": {"ItmId": "1694738780"}}
{ "1347809133": 1, "1694738780": 2 }
{"ReferringUrl": "A", "OpenAccess": "1", "Properties": {"ItmId": "111"}} {"ReferringUrl": "B", "OpenAccess": "0", "Properties": {"ItmId": "222"}} {"ReferringUrl": "C", "OpenAccess": "1", "Properties": {"ItmId": "111"}} {"ReferringUrl": "D", "OpenAccess": "0", "Properties": {"ItmId": "333"}}
{ "111": 2, "222": 1, "333": 1 }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/45170897/jq-count-the-number-of-items-in-json-by-a-specific-key
jq count the number of items in json by a specific key
Eleanor
peak
45,171,347
35
true
so-45170897
qwen/qwen3.7-plus
so-45979477
Given a JSON object with a 'cruises' array, where each cruise has a 'waypoint_cities' array, output the first and last city name for each cruise.
jq '.cruises[].waypoint_cities | first, last'
{"cruises": [{"waypoint_cities": ["Palma de Mallorca", "Cádiz", "Barcelona"]}]}
"Palma de Mallorca" "Barcelona"
{"cruises": [{"waypoint_cities": ["A", "B", "C", "D"]}, {"waypoint_cities": ["X", "Y"]}]}
"A" "D" "X" "Y"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/45979477/extract-the-first-and-the-last-value-of-a-json-array-object
Extract the first and the last value of a json array/object
TimoC
jq170727
45,986,265
36
true
null
null
so-45979477-p1
For each cruise in a JSON object's 'cruises' array, extract the first and last city from its 'waypoint_cities' list.
jq '.cruises[].waypoint_cities | first, last'
{"cruises": [{"waypoint_cities": ["Palma de Mallorca", "Cádiz", "Barcelona"]}]}
"Palma de Mallorca" "Barcelona"
{"cruises": [{"waypoint_cities": ["A", "B", "C", "D"]}, {"waypoint_cities": ["X", "Y"]}]}
"A" "D" "X" "Y"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/45979477/extract-the-first-and-the-last-value-of-a-json-array-object
Extract the first and the last value of a json array/object
TimoC
jq170727
45,986,265
36
true
so-45979477
qwen/qwen3.7-plus
so-46460631
Count the total number of non-null resources across all modules in the JSON object.
jq '[.modules[].resources | select(.[] != null)] | length'
{ "modules": [ { "resources": [ { "name": "res1" }, null, { "name": "res2" } ] }, { "resources": [ { "name": "res3" } ] } ] }
3
{ "modules": [ { "resources": [ null, { "name": "a" } ] }, { "resources": [ { "name": "b" }, { "name": "c" }, null ] }, { "resources": [] } ] }
3
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/46460631/how-can-i-count-number-of-elements-after-query
How can I count number of elements after query?
Konstantin Shestakov
hek2mgl
46,460,707
20
true
null
null
so-46460631-p1
Calculate the total count of non-null resources across all modules in a JSON object.
jq '[.modules[].resources | select(.[] != null)] | length'
{ "modules": [ { "resources": [ { "name": "res1" }, null, { "name": "res2" } ] }, { "resources": [ { "name": "res3" } ] } ] }
3
{ "modules": [ { "resources": [ null, { "name": "a" } ] }, { "resources": [ { "name": "b" }, { "name": "c" }, null ] }, { "resources": [] } ] }
3
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/46460631/how-can-i-count-number-of-elements-after-query
How can I count number of elements after query?
Konstantin Shestakov
hek2mgl
46,460,707
20
true
so-46460631
qwen/qwen3.7-plus
so-46530167
Filter the JSON array to keep only objects where the id is "1" or "2", and output their name and value fields on separate lines.
jq '.[] | select(.id == "1" or .id == "2") | .name, .value'
[ { "id": "1", "name": "sausage", "value": 100 }, { "id": "2", "name": "spam", "value": 200 }, { "id": "3", "name": "eggs", "value": 300 } ]
"sausage" 100 "spam" 200
[ { "id": "1", "name": "apple", "value": 10 }, { "id": "2", "name": "banana", "value": 20 }, { "id": "3", "name": "cherry", "value": 30 }, { "id": "4", "name": "date", "value": 40 } ]
"apple" 10 "banana" 20
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/46530167/jq-select-filter-with-multiple-arguments
JQ select filter with multiple arguments
ccpizza
bhansa
46,530,324
20
true
null
null
so-46530167-p1
Keep only JSON objects with id "1" or "2", then print their name and value fields on separate lines.
jq '.[] | select(.id == "1" or .id == "2") | .name, .value'
[ { "id": "1", "name": "sausage", "value": 100 }, { "id": "2", "name": "spam", "value": 200 }, { "id": "3", "name": "eggs", "value": 300 } ]
"sausage" 100 "spam" 200
[ { "id": "1", "name": "apple", "value": 10 }, { "id": "2", "name": "banana", "value": 20 }, { "id": "3", "name": "cherry", "value": 30 }, { "id": "4", "name": "date", "value": 40 } ]
"apple" 10 "banana" 20
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/46530167/jq-select-filter-with-multiple-arguments
JQ select filter with multiple arguments
ccpizza
bhansa
46,530,324
20
true
so-46530167
qwen/qwen3.7-plus
so-46564720
Generate a JSON array containing the dot-separated paths of all keys in the input JSON object.
jq '[paths | join(".")]'
{"a":1,"b":{"c":2}}
[ "a", "b", "b.c" ]
{"x":10,"y":{"z":{"w":5}}}
[ "x", "y", "y.z", "y.z.w" ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/46564720/how-to-extract-all-also-nested-key-names-with-jq
How to extract all (also nested) key names with jq
wjtk
RomanPerekhrest
46,565,894
24
true
null
null
so-46564720-p1
Produce a JSON array listing the dot-separated paths for every key in the input JSON object.
jq '[paths | join(".")]'
{"a":1,"b":{"c":2}}
[ "a", "b", "b.c" ]
{"x":10,"y":{"z":{"w":5}}}
[ "x", "y", "y.z", "y.z.w" ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/46564720/how-to-extract-all-also-nested-key-names-with-jq
How to extract all (also nested) key names with jq
wjtk
RomanPerekhrest
46,565,894
24
true
so-46564720
qwen/qwen3.7-plus
so-46911763
From the array of objects, find the object where the name is "AAA" and output its members and id values separated by a space.
jq -r '.[] | select(.name=="AAA") | "\(.members) \(.id)"'
[ { "name": "AAA", "members": 10, "profiles": 0, "templates": 0, "ldapGroups": 0, "ldapMembers": 0, "id": "20" }, { "name": "BBB", "members": 5, "id": "30" } ]
10 20
[ { "name": "CCC", "members": 1, "id": "1" }, { "name": "AAA", "members": 99, "profiles": 5, "templates": 2, "ldapGroups": 1, "ldapMembers": 0, "id": "999" } ]
99 999
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/46911763/jq-error-number-and-string-cannot-be-added
jq: error: number and string cannot be added
Chris
hek2mgl
46,912,879
29
true
null
null
so-46911763-p1
Locate the object with name "AAA" in an array and output its members and id separated by a space.
jq -r '.[] | select(.name=="AAA") | "\(.members) \(.id)"'
[ { "name": "AAA", "members": 10, "profiles": 0, "templates": 0, "ldapGroups": 0, "ldapMembers": 0, "id": "20" }, { "name": "BBB", "members": 5, "id": "30" } ]
10 20
[ { "name": "CCC", "members": 1, "id": "1" }, { "name": "AAA", "members": 99, "profiles": 5, "templates": 2, "ldapGroups": 1, "ldapMembers": 0, "id": "999" } ]
99 999
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/46911763/jq-error-number-and-string-cannot-be-added
jq: error: number and string cannot be added
Chris
hek2mgl
46,912,879
29
true
so-46911763
qwen/qwen3.7-plus
so-47355901
Update the values of keys 'two' and 'three' in a JSON object to 'newval' while preserving all other keys.
jq '. + {two: "newval", three: "newval"}'
{ "one": { "val": 1 }, "two": "val", "three": "val", "four": "val" }
{ "one": { "val": 1 }, "two": "newval", "three": "newval", "four": "val" }
{ "alpha": 10, "two": "old", "three": "old", "beta": 20 }
{ "alpha": 10, "two": "newval", "three": "newval", "beta": 20 }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/47355901/jq-change-multiple-values
jq: Change multiple values
OrangePot
jq170727
47,357,956
34
true
null
null
so-47355901-p1
Set the values for keys 'two' and 'three' to 'newval' in a JSON object, leaving other keys unchanged.
jq '. + {two: "newval", three: "newval"}'
{ "one": { "val": 1 }, "two": "val", "three": "val", "four": "val" }
{ "one": { "val": 1 }, "two": "newval", "three": "newval", "four": "val" }
{ "alpha": 10, "two": "old", "three": "old", "beta": 20 }
{ "alpha": 10, "two": "newval", "three": "newval", "beta": 20 }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/47355901/jq-change-multiple-values
jq: Change multiple values
OrangePot
jq170727
47,357,956
34
true
so-47355901
qwen/qwen3.7-plus
so-48529016
Remove the key "maxHeight" from a JSON object if it exists, preserving the rest of the structure.
jq 'del(.maxHeight)'
{ "style": { "className": "feature" }, "maxHeight": "200px", "label": "test" }
{ "style": { "className": "feature" }, "label": "test" }
{ "id": 1, "maxHeight": "100px", "name": "example" }
{ "id": 1, "name": "example" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/48529016/remove-a-keyvalue-from-an-json-object-using-jq
Remove a key:value from an JSON object using jq
MostlyRquestions
exic
60,723,320
26
true
null
null
so-48529016-p1
Delete the "maxHeight" key from a JSON object if present, keeping the remaining structure intact.
jq 'del(.maxHeight)'
{ "style": { "className": "feature" }, "maxHeight": "200px", "label": "test" }
{ "style": { "className": "feature" }, "label": "test" }
{ "id": 1, "maxHeight": "100px", "name": "example" }
{ "id": 1, "name": "example" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/48529016/remove-a-keyvalue-from-an-json-object-using-jq
Remove a key:value from an JSON object using jq
MostlyRquestions
exic
60,723,320
26
true
so-48529016
qwen/qwen3.7-plus
so-49181898
Convert the LastModified timestamp string to a Unix epoch integer by removing milliseconds and parsing the date.
jq '.LastModified |= (sub("\\.000Z";"Z") | fromdate)'
{"LastModified": "2018-03-07T17:24:33.000Z", "Key": "pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json"}
{ "LastModified": 1520443473, "Key": "pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json" }
{"LastModified": "2020-01-01T12:00:00.000Z", "Key": "data/file.json"}
{ "LastModified": 1577880000, "Key": "data/file.json" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/49181898/jq-replace-part-of-value-in-json
jq replace part of value in json
Ryan Loeffler
RomanPerekhrest
49,182,262
19
true
null
null
so-49181898-p1
Parse the LastModified timestamp string into a Unix epoch integer by stripping milliseconds.
jq '.LastModified |= (sub("\\.000Z";"Z") | fromdate)'
{"LastModified": "2018-03-07T17:24:33.000Z", "Key": "pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json"}
{ "LastModified": 1520443473, "Key": "pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json" }
{"LastModified": "2020-01-01T12:00:00.000Z", "Key": "data/file.json"}
{ "LastModified": 1577880000, "Key": "data/file.json" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/49181898/jq-replace-part-of-value-in-json
jq replace part of value in json
Ryan Loeffler
RomanPerekhrest
49,182,262
19
true
so-49181898
qwen/qwen3.7-plus
so-50286066
Decode all base64-encoded values in the 'data' object of a Kubernetes Secret JSON and output the resulting key-value pairs.
jq '.data | map_values(@base64d)'
{ "apiVersion": "v1", "kind": "Secret", "metadata": { "name": "testsecret" }, "data": { "key1": "dmFsMQ==", "key2": "dmFsMg==" } }
{ "key1": "val1", "key2": "val2" }
{ "apiVersion": "v1", "kind": "Secret", "metadata": { "name": "anothersecret" }, "data": { "username": "YWRtaW4=", "password": "cGFzc3dvcmQxMjM=" } }
{ "username": "admin", "password": "password123" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/50286066/kubernetes-kubectl-print-all-secrets
Kubernetes / kubectl print all secrets
s g
peak
50,286,402
27
true
null
null
so-51494389
Extract the value of the key "@def-ghi" located inside the "abc" object from the input JSON.
jq '.abc."@def-ghi"'
{"abc":{"@def-ghi":"value1","xyz":"value2"}}
"value1"
{"abc":{"@def-ghi":"another_value","other":"data"}}
"another_value"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/51494389/escape-field-name-in-jq-that-contains-and
Escape field name in jq that contains '@' and '-'?
shadyabhi
chepner
51,502,506
24
true
null
null
so-51494389-p1
Retrieve the value associated with the key "@def-ghi" within the "abc" object of the input JSON.
jq '.abc."@def-ghi"'
{"abc":{"@def-ghi":"value1","xyz":"value2"}}
"value1"
{"abc":{"@def-ghi":"another_value","other":"data"}}
"another_value"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/51494389/escape-field-name-in-jq-that-contains-and
Escape field name in jq that contains '@' and '-'?
shadyabhi
chepner
51,502,506
24
true
so-51494389
qwen/qwen3.7-plus
so-51837624
Transform the JSON object by setting the value of 'basePath' based on the 'version' string. Split the version by dots; if the first part is '0', set basePath to 'beta' concatenated with the second part, otherwise set it to the first part.
jq '.basePath = (.version | split(".") | if .[0] == "0" then "beta" + .[1] else .[0] end)'
{"version": "0.1.2", "basePath": "/"}
{ "version": "0.1.2", "basePath": "beta1" }
{"version": "1.2.3", "basePath": "/"}
{ "version": "1.2.3", "basePath": "1" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/51837624/jq-split-string-and-assign
jq split string and assign
Rizwan Saeed
peak
51,837,735
19
true
null
null
so-51837624-p1
Update the JSON object's 'basePath' by parsing the 'version' string: split it by dots, and if the first segment is '0', set 'basePath' to 'beta' plus the second segment; otherwise, use the first segment.
jq '.basePath = (.version | split(".") | if .[0] == "0" then "beta" + .[1] else .[0] end)'
{"version": "0.1.2", "basePath": "/"}
{ "version": "0.1.2", "basePath": "beta1" }
{"version": "1.2.3", "basePath": "/"}
{ "version": "1.2.3", "basePath": "1" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/51837624/jq-split-string-and-assign
jq split string and assign
Rizwan Saeed
peak
51,837,735
19
true
so-51837624
qwen/qwen3.7-plus
so-56355822
From the nested addresses object, find the address entry where the version is 4 and output its addr value. The key for the addresses list is dynamic and unknown.
jq '.details.addresses[][] | select(.version == 4).addr'
{ "details": { "car": "bmw", "addresses": { "ext-118-21-8-0-29": [ { "version": 4, "addr": "89 Psr" }, { "version": 6, "addr": "56 apT" } ] } } }
"89 Psr"
{ "details": { "car": "audi", "addresses": { "dynamic-key-123": [ { "version": 6, "addr": "::1" }, { "version": 4, "addr": "192.168.1.1" } ] } } }
"192.168.1.1"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/56355822/how-to-use-jq-wildcard
How to use jq wildcard
executable
Jeff Mercado
56,356,012
28
true
null
null
so-56355822-p1
Locate the address entry with version 4 within the dynamically keyed addresses object and return its 'addr' value.
jq '.details.addresses[][] | select(.version == 4).addr'
{ "details": { "car": "bmw", "addresses": { "ext-118-21-8-0-29": [ { "version": 4, "addr": "89 Psr" }, { "version": 6, "addr": "56 apT" } ] } } }
"89 Psr"
{ "details": { "car": "audi", "addresses": { "dynamic-key-123": [ { "version": 6, "addr": "::1" }, { "version": 4, "addr": "192.168.1.1" } ] } } }
"192.168.1.1"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/56355822/how-to-use-jq-wildcard
How to use jq wildcard
executable
Jeff Mercado
56,356,012
28
true
so-56355822
qwen/qwen3.7-plus
so-56555155
Given a JSON object with a "columns" key containing an object of column definitions, extract the value of the "required" field for the column named "id". If the "required" field is missing, default to false.
jq '.columns.id | if has("required") then .required else false end'
{ "columns": { "id": { "required": true, "type": "integer" }, "name": { "required": false, "type": "string" } } }
true
{ "columns": { "id": { "type": "integer" }, "name": { "required": true, "type": "string" } } }
false
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq
Get or default function in JQ?
Yun Huang
peak
56,555,442
30
true
null
null
so-56555155-p1
From the "columns" definitions in the JSON, get the "required" status for the "id" column, defaulting to false if the field is absent.
jq '.columns.id | if has("required") then .required else false end'
{ "columns": { "id": { "required": true, "type": "integer" }, "name": { "required": false, "type": "string" } } }
true
{ "columns": { "id": { "type": "integer" }, "name": { "required": true, "type": "string" } } }
false
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq
Get or default function in JQ?
Yun Huang
peak
56,555,442
30
true
so-56555155
qwen/qwen3.7-plus
so-56692037
Given a stream of JSON objects, output lines in the format 'key: value' for any key whose value is either an empty string or null. For empty strings, wrap the value in double quotes in the output.
jq -r 'to_entries[] | select(.value | . == null or . == "") | if .value == "" then .value |= "\"\(.)\"" else . end | "\(.key): \(.value)"'
{"name": "Color TV", "price": "1200", "available": ""} {"name": "DVD player", "price": "200", "color": null}
available: "" color: null
{"a": 1, "b": "", "c": null} {"x": "hello", "y": 0}
b: "" c: null
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/56692037/filter-empty-and-or-null-values-with-jq
Filter empty and/or null values with jq
Fernando César
peak
56,694,468
38
true
null
null
so-56692037-p1
For a stream of JSON objects, print 'key: value' lines for keys with null or empty string values, ensuring empty strings are enclosed in double quotes.
jq -r 'to_entries[] | select(.value | . == null or . == "") | if .value == "" then .value |= "\"\(.)\"" else . end | "\(.key): \(.value)"'
{"name": "Color TV", "price": "1200", "available": ""} {"name": "DVD player", "price": "200", "color": null}
available: "" color: null
{"a": 1, "b": "", "c": null} {"x": "hello", "y": 0}
b: "" c: null
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/56692037/filter-empty-and-or-null-values-with-jq
Filter empty and/or null values with jq
Fernando César
peak
56,694,468
38
true
so-56692037
qwen/qwen3.7-plus
so-70100534
Extract the first three elements of the 'identifier' array from a JSON object, keeping only the 'system' and 'value' fields for each.
jq '.identifier[:3] | map({system, value})'
{"resourceType": "Practitioner", "id": "328001", "identifier": [{"use": "official", "system": "urn:oid:1.3.6.1.4.1.19126.3", "value": "00396185X"}, {"use": "official", "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515"}, {"use": "official", "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515"}, {"use": "off...
[ { "system": "urn:oid:1.3.6.1.4.1.19126.3", "value": "00396185X" }, { "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515" }, { "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515" } ]
{"resourceType": "Practitioner", "id": "123", "identifier": [{"system": "sys1", "value": "val1", "extra": "ignore"}, {"system": "sys2", "value": "val2"}, {"system": "sys3", "value": "val3"}, {"system": "sys4", "value": "val4"}, {"system": "sys5", "value": "val5"}]}
[ { "system": "sys1", "value": "val1" }, { "system": "sys2", "value": "val2" }, { "system": "sys3", "value": "val3" } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/70100534/jq-get-first-n-elements-of-an-array-field
jq: get first n elements of an array field
Jordi
Inian
70,100,645
22
true
null
null
so-70100534-p1
Take the first three items from the 'identifier' array in the JSON object and retain only their 'system' and 'value' fields.
jq '.identifier[:3] | map({system, value})'
{"resourceType": "Practitioner", "id": "328001", "identifier": [{"use": "official", "system": "urn:oid:1.3.6.1.4.1.19126.3", "value": "00396185X"}, {"use": "official", "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515"}, {"use": "official", "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515"}, {"use": "off...
[ { "system": "urn:oid:1.3.6.1.4.1.19126.3", "value": "00396185X" }, { "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515" }, { "system": "urn:oid:2.16.724.4.9.10.2", "value": "0831515" } ]
{"resourceType": "Practitioner", "id": "123", "identifier": [{"system": "sys1", "value": "val1", "extra": "ignore"}, {"system": "sys2", "value": "val2"}, {"system": "sys3", "value": "val3"}, {"system": "sys4", "value": "val4"}, {"system": "sys5", "value": "val5"}]}
[ { "system": "sys1", "value": "val1" }, { "system": "sys2", "value": "val2" }, { "system": "sys3", "value": "val3" } ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/70100534/jq-get-first-n-elements-of-an-array-field
jq: get first n elements of an array field
Jordi
Inian
70,100,645
22
true
so-70100534
qwen/qwen3.7-plus
so-18796515
Filter the LoadBalancerDescriptions array to include only objects where the AvailabilityZones array contains the string "us-east-1b", and output the CanonicalHostedZoneName and AvailabilityZones for each match.
jq '.LoadBalancerDescriptions[] | select(.AvailabilityZones[] == "us-east-1b") | {CanonicalHostedZoneName, AvailabilityZones}'
{"LoadBalancerDescriptions": [{"AvailabilityZones": ["us-east-1b", "us-east-1c"], "CanonicalHostedZoneName": "example-1.elb.amazonaws.com"}, {"AvailabilityZones": ["us-west-2a"], "CanonicalHostedZoneName": "example-2.elb.amazonaws.com"}]}
{ "CanonicalHostedZoneName": "example-1.elb.amazonaws.com", "AvailabilityZones": [ "us-east-1b", "us-east-1c" ] }
{"LoadBalancerDescriptions": [{"AvailabilityZones": ["us-east-1d"], "CanonicalHostedZoneName": "skip-me.elb.amazonaws.com"}, {"AvailabilityZones": ["us-east-1b", "us-east-1c", "us-east-1d"], "CanonicalHostedZoneName": "keep-me.elb.amazonaws.com"}]}
{ "CanonicalHostedZoneName": "keep-me.elb.amazonaws.com", "AvailabilityZones": [ "us-east-1b", "us-east-1c", "us-east-1d" ] }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/18796515/using-jq-to-parse-json-output-of-aws-cli
Using jq to parse json output of AWS CLI
cp_clegg
konsolebox
18,796,928
7
true
null
null
so-18796515-p1
From the LoadBalancerDescriptions array, select entries where the AvailabilityZones list includes "us-east-1b", then output the CanonicalHostedZoneName and AvailabilityZones for each selected entry.
jq '.LoadBalancerDescriptions[] | select(.AvailabilityZones[] == "us-east-1b") | {CanonicalHostedZoneName, AvailabilityZones}'
{"LoadBalancerDescriptions": [{"AvailabilityZones": ["us-east-1b", "us-east-1c"], "CanonicalHostedZoneName": "example-1.elb.amazonaws.com"}, {"AvailabilityZones": ["us-west-2a"], "CanonicalHostedZoneName": "example-2.elb.amazonaws.com"}]}
{ "CanonicalHostedZoneName": "example-1.elb.amazonaws.com", "AvailabilityZones": [ "us-east-1b", "us-east-1c" ] }
{"LoadBalancerDescriptions": [{"AvailabilityZones": ["us-east-1d"], "CanonicalHostedZoneName": "skip-me.elb.amazonaws.com"}, {"AvailabilityZones": ["us-east-1b", "us-east-1c", "us-east-1d"], "CanonicalHostedZoneName": "keep-me.elb.amazonaws.com"}]}
{ "CanonicalHostedZoneName": "keep-me.elb.amazonaws.com", "AvailabilityZones": [ "us-east-1b", "us-east-1c", "us-east-1d" ] }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/18796515/using-jq-to-parse-json-output-of-aws-cli
Using jq to parse json output of AWS CLI
cp_clegg
konsolebox
18,796,928
7
true
so-18796515
qwen/qwen3.7-plus
so-18837939
Transform an array of arrays by extracting the first element from each subarray.
jq 'map(.[0])'
[ [ "sequence", "int" ], [ "time", "string" ] ]
[ "sequence", "time" ]
[ [ "id", "integer" ], [ "name", "text" ], [ "active", "boolean" ] ]
[ "id", "name", "active" ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/18837939/select-nth-element-from-multidimensional-json-array-with-jq
Select nth element from multidimensional JSON array with jq
Dreen
Psylone
18,890,702
10
true
null
null
so-18837939-p1
Map over an array of arrays to produce a new array consisting of the first element from each inner array.
jq 'map(.[0])'
[ [ "sequence", "int" ], [ "time", "string" ] ]
[ "sequence", "time" ]
[ [ "id", "integer" ], [ "name", "text" ], [ "active", "boolean" ] ]
[ "id", "name", "active" ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/18837939/select-nth-element-from-multidimensional-json-array-with-jq
Select nth element from multidimensional JSON array with jq
Dreen
Psylone
18,890,702
10
true
so-18837939
qwen/qwen3.7-plus
so-24875419
From a JSON object containing a 'students' array, return an array of objects with 'name', 'age', 'gpa' (from cum_gpa), and 'CSC101' grade for students who received an 'A' in CSC101. The CSC101 grade should be extracted by merging grades from all semesters.
jq '.students | map({name: .name, age: .age, gpa: .cum_gpa, CSC101: (.semesters | map(.grades) | add | .CSC101)} | select(.CSC101 == "A"))'
{ "students": [ { "name": "John", "age": "19", "gender": "m", "from": "Tampa, FL", "cum_gpa": "3.83", "semesters": [ { "name": "201302", "gpa": "3.67", "grades": { "CSC101": "A", "MAT101": "A", "PSY101": ...
[ { "name": "John", "age": "19", "gpa": "3.83", "CSC101": "A" }, { "name": "Mary", "age": "20", "gpa": "3.50", "CSC101": "A" } ]
{ "students": [ { "name": "Alice", "age": "21", "gender": "f", "from": "Boston, MA", "cum_gpa": "3.90", "semesters": [ { "name": "202301", "gpa": "3.90", "grades": { "CSC101": "A", "ENG101": "A" } }...
[ { "name": "Alice", "age": "21", "gpa": "3.90", "CSC101": "A" } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/24875419/complex-jq-filter
Complex jq Filter
AJ.
Jeff Mercado
24,875,844
6
true
null
null
so-28103489
Given an input array containing two arrays, where the first array holds keys and the second holds corresponding values, construct a single JSON object mapping those keys to those values.
jq '.[0] as $keys | .[1] as $values | reduce range(0; $keys|length) as $i ( {}; . + { ($keys[$i]): $values[$i] })'
[["key1", "key2"], ["val1", "val2"]]
{ "key1": "val1", "key2": "val2" }
[["name", "age", "city"], ["Alice", 30, "NYC"]]
{ "name": "Alice", "age": 30, "city": "NYC" }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/28103489/create-object-from-array-of-keys-and-values
Create object from array of keys and values
Abdullah Jibaly
Abdullah Jibaly
28,117,842
9
true
null
null
so-28103489-p1
Create a JSON object by pairing keys from the first subarray with values from the second subarray of the input two-element array.
jq '.[0] as $keys | .[1] as $values | reduce range(0; $keys|length) as $i ( {}; . + { ($keys[$i]): $values[$i] })'
[["key1", "key2"], ["val1", "val2"]]
{ "key1": "val1", "key2": "val2" }
[["name", "age", "city"], ["Alice", 30, "NYC"]]
{ "name": "Alice", "age": 30, "city": "NYC" }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/28103489/create-object-from-array-of-keys-and-values
Create object from array of keys and values
Abdullah Jibaly
Abdullah Jibaly
28,117,842
9
true
so-28103489
qwen/qwen3.7-plus
so-28458046
Filter an array of objects to keep only those where the 'Selected' field is not null, and project specific fields into a new object for each kept item. Return the result as a single JSON array.
jq -c '[.[] | select(.Selected != null) | {"Head Of House Name", "Head Of House Phone", "Family Phone"}]'
[ { "Selected": null, "Family Name": "Jones", "Head Of House Name": "Jones, Adam", "Head Of House Phone": "111", "Family Phone": "222" }, { "Selected": "x", "Family Name": "Xiong", "Head Of House Name": "Xiong, Arlene", "Head Of House Phone": "333", "Family Phone": null }...
[{"Head Of House Name":"Xiong, Arlene","Head Of House Phone":"333","Family Phone":null}]
[ { "Selected": "x", "Family Name": "Blair", "Head Of House Name": "Blair, Toby", "Head Of House Phone": "444", "Family Phone": "555" }, { "Selected": null, "Family Name": "Smith", "Head Of House Name": "Smith, John", "Head Of House Phone": "666", "Family Phone": "777" } ...
[{"Head Of House Name":"Blair, Toby","Head Of House Phone":"444","Family Phone":"555"}]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/28458046/how-can-i-filter-an-array-of-json-objects-using-jq
How can I filter an array of json objects using jq?
David Vezzani
Jeff Mercado
28,461,226
10
true
null
null
so-28458046-p1
Filter an array of objects to retain only those with a non-null 'Selected' field, project specific fields into new objects for these items, and return the result as a JSON array.
jq -c '[.[] | select(.Selected != null) | {"Head Of House Name", "Head Of House Phone", "Family Phone"}]'
[ { "Selected": null, "Family Name": "Jones", "Head Of House Name": "Jones, Adam", "Head Of House Phone": "111", "Family Phone": "222" }, { "Selected": "x", "Family Name": "Xiong", "Head Of House Name": "Xiong, Arlene", "Head Of House Phone": "333", "Family Phone": null }...
[{"Head Of House Name":"Xiong, Arlene","Head Of House Phone":"333","Family Phone":null}]
[ { "Selected": "x", "Family Name": "Blair", "Head Of House Name": "Blair, Toby", "Head Of House Phone": "444", "Family Phone": "555" }, { "Selected": null, "Family Name": "Smith", "Head Of House Name": "Smith, John", "Head Of House Phone": "666", "Family Phone": "777" } ...
[{"Head Of House Name":"Blair, Toby","Head Of House Phone":"444","Family Phone":"555"}]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/28458046/how-can-i-filter-an-array-of-json-objects-using-jq
How can I filter an array of json objects using jq?
David Vezzani
Jeff Mercado
28,461,226
10
true
so-28458046
qwen/qwen3.7-plus
so-29259249
For each object in the input JSON array, retain only the NAME and NAME_LONG keys within the properties object, keeping all other top-level keys intact.
jq 'map(.properties |= with_entries(select(.key == ("NAME", "NAME_LONG"))))'
[{"geometry": {"type": "Polygon", "coordinates": [[[-69.9, 12.5]]]}, "type": "Feature", "properties": {"NAME": "Aruba", "WB_A2": "AW", "INCOME_GRP": "High", "NAME_LONG": "Aruba"}}, {"geometry": {"type": "MultiPolygon", "coordinates": [[[-63.0, 18.2]]]}, "type": "Feature", "properties": {"NAME": "Anguilla", "WB_A2": "-9...
[ { "geometry": { "type": "Polygon", "coordinates": [ [ [ -69.9, 12.5 ] ] ] }, "type": "Feature", "properties": { "NAME": "Aruba", "NAME_LONG": "Aruba" } }, { "geometry": { "type": "MultiPolygon...
[{"geometry": {"type": "Point", "coordinates": [0, 0]}, "type": "Feature", "properties": {"NAME": "Test", "CODE": "T1", "POP": 100, "NAME_LONG": "Test Island"}}]
[ { "geometry": { "type": "Point", "coordinates": [ 0, 0 ] }, "type": "Feature", "properties": { "NAME": "Test", "NAME_LONG": "Test Island" } } ]
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/29259249/extracting-selected-properties-from-a-nested-json-object-with-jq
Extracting selected properties from a nested JSON object with jq
Rob Cowie
Jeff Mercado
29,259,478
9
true
null
null
so-29259249-p1
For every object in the input JSON array, preserve all top-level keys but restrict the 'properties' object to only include 'NAME' and 'NAME_LONG'.
jq 'map(.properties |= with_entries(select(.key == ("NAME", "NAME_LONG"))))'
[{"geometry": {"type": "Polygon", "coordinates": [[[-69.9, 12.5]]]}, "type": "Feature", "properties": {"NAME": "Aruba", "WB_A2": "AW", "INCOME_GRP": "High", "NAME_LONG": "Aruba"}}, {"geometry": {"type": "MultiPolygon", "coordinates": [[[-63.0, 18.2]]]}, "type": "Feature", "properties": {"NAME": "Anguilla", "WB_A2": "-9...
[ { "geometry": { "type": "Polygon", "coordinates": [ [ [ -69.9, 12.5 ] ] ] }, "type": "Feature", "properties": { "NAME": "Aruba", "NAME_LONG": "Aruba" } }, { "geometry": { "type": "MultiPolygon...
[{"geometry": {"type": "Point", "coordinates": [0, 0]}, "type": "Feature", "properties": {"NAME": "Test", "CODE": "T1", "POP": 100, "NAME_LONG": "Test Island"}}]
[ { "geometry": { "type": "Point", "coordinates": [ 0, 0 ] }, "type": "Feature", "properties": { "NAME": "Test", "NAME_LONG": "Test Island" } } ]
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/29259249/extracting-selected-properties-from-a-nested-json-object-with-jq
Extracting selected properties from a nested JSON object with jq
Rob Cowie
Jeff Mercado
29,259,478
9
true
so-29259249
qwen/qwen3.7-plus
so-30768196
Extract OptionGroupName, InstanceIdentifier, and Version from each collection item and output them as tab-separated values.
jq -r '.Collections[] | [.OptionGroups[].OptionGroupName, .InstanceIdentifier, .Version] | join("\t")'
{"Collections": [{"OptionGroups": [{"OptionGroupName": "Test1", "Status": "in-sync"}], "Version": "3.4.25", "InstanceIdentifier": "Dev1"}, {"OptionGroups": [{"OptionGroupName": "Test2", "Status": "in-sync"}], "Version": "3.4.22", "InstanceIdentifier": "Dev2"}]} {"Collections": [{"OptionGroups": [{"OptionGroupName": "Pr...
Test1 Dev1 3.4.25 Test2 Dev2 3.4.22 Prod1 Main1 5.0.0
{"Collections": [{"OptionGroups": [{"OptionGroupName": "Test1", "Status": "in-sync"}], "Version": "3.4.25", "InstanceIdentifier": "Dev1"}, {"OptionGroups": [{"OptionGroupName": "Test2", "Status": "in-sync"}], "Version": "3.4.22", "InstanceIdentifier": "Dev2"}]}
Test1 Dev1 3.4.25 Test2 Dev2 3.4.22
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/30768196/multiple-filters-using-jq
Multiple filters using JQ
jago
Jeff Mercado
30,769,322
7
true
null
null
so-30768196-p1
Retrieve OptionGroupName, InstanceIdentifier, and Version from each item in the collection and format the output as tab-separated values.
jq -r '.Collections[] | [.OptionGroups[].OptionGroupName, .InstanceIdentifier, .Version] | join("\t")'
{"Collections": [{"OptionGroups": [{"OptionGroupName": "Test1", "Status": "in-sync"}], "Version": "3.4.25", "InstanceIdentifier": "Dev1"}, {"OptionGroups": [{"OptionGroupName": "Test2", "Status": "in-sync"}], "Version": "3.4.22", "InstanceIdentifier": "Dev2"}]} {"Collections": [{"OptionGroups": [{"OptionGroupName": "Pr...
Test1 Dev1 3.4.25 Test2 Dev2 3.4.22 Prod1 Main1 5.0.0
{"Collections": [{"OptionGroups": [{"OptionGroupName": "Test1", "Status": "in-sync"}], "Version": "3.4.25", "InstanceIdentifier": "Dev1"}, {"OptionGroups": [{"OptionGroupName": "Test2", "Status": "in-sync"}], "Version": "3.4.22", "InstanceIdentifier": "Dev2"}]}
Test1 Dev1 3.4.25 Test2 Dev2 3.4.22
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/30768196/multiple-filters-using-jq
Multiple filters using JQ
jago
Jeff Mercado
30,769,322
7
true
so-30768196
qwen/qwen3.7-plus
so-31161831
Read a JSON object with a numeric 'version' field and output a new JSON object with a field 'v' that is the version number incremented by 1.
jq '{"v":(.version+1)}'
{"version":1}
{ "v": 2 }
{"version":5}
{ "v": 6 }
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/31161831/how-to-increment-a-number-when-transforming-json
How to increment a number when transforming json
neurolabs
Rambo Ramon
31,162,086
5
true
null
null
so-31161831-p1
Take a JSON object with a numeric 'version' property and return a new object where the field 'v' equals the original version plus one.
jq '{"v":(.version+1)}'
{"version":1}
{ "v": 2 }
{"version":5}
{ "v": 6 }
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/31161831/how-to-increment-a-number-when-transforming-json
How to increment a number when transforming json
neurolabs
Rambo Ramon
31,162,086
5
true
so-31161831
qwen/qwen3.7-plus
so-32275538
Transform each JSON object in the input stream into a CSV line containing the ClassIdentifier, StateMode (or 'null' if missing/null), and a pipe-separated sorted list of active StateGroupNames (or 'null' if empty).
jq -r '[.ClassIdentifier, (.StateMode // "null"), (.StateGroups | map(select(.Status=="active").StateGroupName) | sort | join("|") | if .=="" then "null" else . end)] | @csv'
{"ClassIdentifier": "consumer-leads", "StateMode": "txt-2300", "StateGroups": []} {"ClassIdentifier": "main", "StateMode": null, "StateGroups": [{"Status": "active", "StateGroupName": "default"}, {"Status": "active", "StateGroupName": "brown-space"}, {"Status": "active", "StateGroupName": "txt-hosts"}]}
"consumer-leads","txt-2300","null" "main","null","brown-space|default|txt-hosts"
{"ClassIdentifier": "paid-media", "StateMode": "txt-2300", "StateGroups": []} {"ClassIdentifier": "reports", "StateMode": null, "StateGroups": [{"Status": "active", "StateGroupName": "txt-hosts"}, {"Status": "active", "StateGroupName": "grey-space"}, {"Status": "active", "StateGroupName": "default"}]}
"paid-media","txt-2300","null" "reports","null","default|grey-space|txt-hosts"
real-stackoverflow
3
train
stackoverflow-accepted-answer
CC-BY-SA-4.0
https://stackoverflow.com/questions/32275538/make-jq-transform-an-array-of-objects-to-a-string
Make JQ transform an array of objects to a string
jago
Jeff Mercado
32,276,111
9
true
null
null
so-32275538-p1
Convert each input JSON object into a CSV row featuring ClassIdentifier, StateMode (defaulting to 'null' if absent or null), and a pipe-delimited, sorted list of active StateGroupNames (defaulting to 'null' if empty).
jq -r '[.ClassIdentifier, (.StateMode // "null"), (.StateGroups | map(select(.Status=="active").StateGroupName) | sort | join("|") | if .=="" then "null" else . end)] | @csv'
{"ClassIdentifier": "consumer-leads", "StateMode": "txt-2300", "StateGroups": []} {"ClassIdentifier": "main", "StateMode": null, "StateGroups": [{"Status": "active", "StateGroupName": "default"}, {"Status": "active", "StateGroupName": "brown-space"}, {"Status": "active", "StateGroupName": "txt-hosts"}]}
"consumer-leads","txt-2300","null" "main","null","brown-space|default|txt-hosts"
{"ClassIdentifier": "paid-media", "StateMode": "txt-2300", "StateGroups": []} {"ClassIdentifier": "reports", "StateMode": null, "StateGroups": [{"Status": "active", "StateGroupName": "txt-hosts"}, {"Status": "active", "StateGroupName": "grey-space"}, {"Status": "active", "StateGroupName": "default"}]}
"paid-media","txt-2300","null" "reports","null","default|grey-space|txt-hosts"
real-stackoverflow
3
train
openrouter-paraphrase
CC-BY-SA-4.0
https://stackoverflow.com/questions/32275538/make-jq-transform-an-array-of-objects-to-a-string
Make JQ transform an array of objects to a string
jago
Jeff Mercado
32,276,111
9
true
so-32275538
qwen/qwen3.7-plus
End of preview. Expand in Data Studio

Jqweave Real Training Data

Real natural-language-to-jq training tasks derived from Stack Overflow questions ranked 101–200 and 301–600 by votes, with accepted answers. These source questions are disjoint from the 50-task asterbraid/jqweave-so-data benchmark and the 49-task asterbraid/jqweave-frozen-data validation set.

Contents

  • 174 unique reviewed tasks with two representative inputs each.
  • 169 guarded paraphrases, for 343 training rows total.
  • 686 successful executions, 0 errors with jq-1.6.
  • Zero source-question, input-text, or request/command overlap with either evaluation set or asterbraid/jqweave-data.

Every reference command was executed on both inputs. Requests and commands were manually reviewed. Paraphrases were generated only for training rows and passed numeric and quoted-literal preservation checks.

Source and attribution

Each row includes question_url, question_title, question_owner, answer_owner, and answer_id. ATTRIBUTION.md lists every source. Original Stack Overflow content and derived rows are CC BY-SA 4.0. Collection, review, expansion, and validation code is Apache-2.0.

from datasets import load_dataset

train = load_dataset("asterbraid/jqweave-real-train-data", split="train")

Limitations

This is a small, high-vote sample selected for compatibility with single-stream input and the safety guard. Exact outputs on two representative inputs do not prove correctness on every possible input.

Downloads last month
17

Models trained or fine-tuned on asterbraid/jqweave-real-train-data

Collection including asterbraid/jqweave-real-train-data