Datasets:
id stringlengths 11 11 | request stringlengths 45 328 | command stringlengths 16 222 | input_text stringlengths 6 1.18k | expected_output stringlengths 4 351 | validation_input stringlengths 7 393 | validation_output stringlengths 2 381 | family stringclasses 1
value | difficulty int64 3 3 | split stringclasses 1
value | source stringclasses 1
value | license stringclasses 1
value | question_url stringlengths 60 124 | question_title stringlengths 16 83 | question_owner stringlengths 3 17 | answer_owner stringlengths 3 15 | answer_id int64 24.6M 74.2M | question_score int64 10 18 | reviewed bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
so-18972180 | Given a JSON object, output a new object where each top-level key (except 'data') maps to an array of its immediate child keys. | jq '[(keys - ["data"])[] as $key | { ($key): .[$key] | keys }] | add' | {"acquisition_parameters": {"laser": {"wavelength": {"value": 632}}, "date": "02/03/2525", "camera": {}}, "software": {"repo": "github.com/user/repo", "commit": "a7642f", "branch": "develop"}, "data": [{},{},{}]} | {
"acquisition_parameters": [
"camera",
"date",
"laser"
],
"software": [
"branch",
"commit",
"repo"
]
}
| {"config": {"host": "localhost", "port": 8080}, "metadata": {"version": "1.0", "author": "admin"}, "data": []} | {
"config": [
"host",
"port"
],
"metadata": [
"author",
"version"
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/18972180/using-jq-to-list-keys-in-a-json-object | Using jq to list keys in a JSON object | Ryan | mwag | 28,445,937 | 17 | true |
so-24528256 | Transform an array of strings into an array of objects where each object has a "name" field containing the string and an "index" field containing its original zero-based index. | jq 'to_entries | map({name:.value, index:.key})' | ["a", "b"] | [
{
"name": "a",
"index": 0
},
{
"name": "b",
"index": 1
}
]
| ["apple", "banana", "cherry"] | [
{
"name": "apple",
"index": 0
},
{
"name": "banana",
"index": 1
},
{
"name": "cherry",
"index": 2
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/24528256/how-do-i-add-an-index-in-jq | How do i add an index in jq | Eric Hartford | Jeff Mercado | 24,568,571 | 17 | true |
so-25001349 | From an object containing a 'Tags' array of key-value pairs, extract the 'Value' corresponding to the entry where 'Key' is 'Type'. | jq -r '.Tags[] | select(.Key == "Type") | .Value' | {"Tags": [{"Key": "Name", "Value": "foo"}, {"Key": "Type", "Value": "C"}]}
{"Tags": [{"Key": "Env", "Value": "prod"}, {"Key": "Type", "Value": "B"}]} | C
B
| {"Tags": [{"Key": "Type", "Value": "X"}, {"Key": "Name", "Value": "bar"}]}
{"Tags": [{"Key": "Name", "Value": "baz"}, {"Key": "Type", "Value": "Y"}]} | X
Y
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/25001349/conditionally-print-value-based-on-the-value-of-another-key | Conditionally print value based on the value of another key | stuckintheshuck | PeterM | 25,001,531 | 10 | true |
so-25780807 | Recursively search for the value of the key 'element' within any object nested under the key 'level3', which itself is nested under 'level1'. Return all found values. | jq '.level1 | .. | objects | select(has("level3")) | .level3.element' | {"level1": {"a": {"level3": {"element": "val1"}}, "b": {"level3": {"element": "val2"}, "other": {"level3": {"element": "val3"}}}}} | "val1"
"val2"
"val3"
| {"level1": {"x": {"level3": {"element": "foo"}}, "y": {"z": {"level3": {"element": "bar"}}}}} | "foo"
"bar"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/25780807/how-can-i-use-a-relative-path-or-a-wildcard-in-jq | How can I use a relative Path or a Wildcard in JQ | Mirko Ebert | Jeff Mercado | 25,781,241 | 10 | true |
so-29396154 | Compute the set difference of the 'all' array minus the 'some' array. | jq '.all - .some' | {"all":["A","B","C","ABC"],"some":["B","C"]} | [
"A",
"ABC"
]
| {"all":[1,2,3,4],"some":[2,4]} | [
1,
3
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/29396154/jq-setdiff-of-two-arrays | JQ: setdiff of two arrays | Jon | Jon | 29,417,648 | 13 | true |
so-31035704 | Read a JSON Lines stream of objects with 'machine' and 'domain' fields. Group by machine, then for each machine calculate the total count of records and a breakdown of counts per unique domain. Output an array of objects containing 'machine', 'total', and 'domains' (an object mapping domain names to their counts). | jq -s 'group_by(.machine) | map({"machine": .[0].machine, "total": length, "domains": (group_by(.domain) | map({"key": .[0].domain, "value": length}) | from_entries)})' | {"machine": "possible_victim01", "domain": "evil.com", "timestamp":1435071870}
{"machine": "possible_victim01", "domain": "evil.com", "timestamp":1435071875}
{"machine": "possible_victim01", "domain": "soevil.com", "timestamp":1435071877}
{"machine": "possible_victim02", "domain": "bad.com", "timestamp":1435071877}
{"m... | [
{
"machine": "possible_victim01",
"total": 3,
"domains": {
"evil.com": 2,
"soevil.com": 1
}
},
{
"machine": "possible_victim02",
"total": 1,
"domains": {
"bad.com": 1
}
},
{
"machine": "possible_victim03",
"total": 1,
"domains": {
"soevil.c... | {"machine": "hostA", "domain": "x.com", "timestamp":100}
{"machine": "hostA", "domain": "y.com", "timestamp":101}
{"machine": "hostB", "domain": "x.com", "timestamp":102} | [
{
"machine": "hostA",
"total": 2,
"domains": {
"x.com": 1,
"y.com": 1
}
},
{
"machine": "hostB",
"total": 1,
"domains": {
"x.com": 1
}
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/31035704/use-jq-to-count-on-multiple-levels | Use jq to count on multiple levels | JustChill | Jimmy | 31,036,137 | 12 | true |
so-31694182 | Add a new key-value pair "freshly": "added" to the nested object named "nested" in the input JSON, preserving all other existing keys. | jq '.nested.freshly = "added"' | {
"some": "property",
"nested": {
"hello": "world"
}
} | {
"some": "property",
"nested": {
"hello": "world",
"freshly": "added"
}
}
| {
"id": 1,
"data": {
"x": 10
},
"nested": {
"a": 1,
"b": 2
}
} | {
"id": 1,
"data": {
"x": 10
},
"nested": {
"a": 1,
"b": 2,
"freshly": "added"
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/31694182/how-to-modify-a-nested-object-with-jq | How to modify a nested object with jq | ValLeNain | Jeff Mercado | 31,694,658 | 17 | true |
so-34165201 | Find all paths in the JSON structure where the value is exactly the string 'foo'. Return these paths as an array of arrays representing the indices/keys. | jq '[paths as $path | select(getpath($path) == "foo") | $path]' | {"json": ["a", ["b", "c", ["d", "foo", 1], [[42, "foo"]]]]} | [
[
"json",
1,
2,
1
],
[
"json",
1,
3,
0,
1
]
]
| {"data": {"nested": ["foo", {"inner": "foo"}]}} | [
[
"data",
"nested",
0
],
[
"data",
"nested",
1,
"inner"
]
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/34165201/how-to-get-the-index-path-of-found-values-using-jq | How to get the index path of found values using jq? | Ortwin Gentz | user3899165 | 34,166,237 | 10 | true |
so-37328327 | Extract the substring after 'task/' from the input string using a regular expression match. | jq 'match("(.*task?)\\/(.*$)").captures[1].string' | "arn:aws:ecs:eu-west-1:foo:task/blablabla" | "blablabla"
| "arn:aws:s3:::bucket/task/my-task-id-123" | "my-task-id-123"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37328327/apply-regex-on-jq | Apply regex on JQ | paul | user3899165 | 37,329,187 | 18 | true |
so-37864617 | Transform the input JSON by iterating over the 'things' array. For each item, create an object containing the 'name' and a 'category' field. The 'category' value should be extracted from the 'params' array where the 'key' is 'category'. | jq '.things | .[] | {name: .name, category: .params | .[] | select(.key=="category") | .value }' | {"things":[{"name":"foo","params":[{"type":"t1","key":"key1","value":"val1"},{"type":"t1","key":"category","value":"thefoocategory"}]},{"name":"bar","params":[{"type":"t1","key":"key1","value":"val1"},{"type":"t1","key":"category","value":"thebarcategory"}]}]} | {
"name": "foo",
"category": "thefoocategory"
}
{
"name": "bar",
"category": "thebarcategory"
}
| {"things":[{"name":"alpha","params":[{"type":"t2","key":"id","value":"101"},{"type":"t2","key":"category","value":"catA"}]},{"name":"beta","params":[{"type":"t2","key":"id","value":"102"},{"type":"t2","key":"category","value":"catB"}]}]} | {
"name": "alpha",
"category": "catA"
}
{
"name": "beta",
"category": "catB"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37864617/how-to-use-jq-to-create-an-object-with-an-arbitrary-key-from-a-sub-array | How to use jq to create an object with an arbitrary key from a sub array? | geoff | geoff | 37,865,896 | 18 | true |
so-38364458 | Read a single JSON array from stdin. Compute the intersection of this array with the hardcoded array [2, 4, 6, 8, 10]. The result should be an array of elements present in both arrays, preserving the order of the input array but removing duplicates if necessary to match set intersection logic (unique common elements). | jq 'reduce .[] as $x ([]; if ($x | IN([2, 4, 6, 8, 10][])) and (. | index($x) == null) then . + [$x] else . end)' | [1, 2, 3, 4] | [
2,
4
]
| [5, 6, 7, 8, 9, 10] | [
6,
8,
10
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38364458/how-to-get-the-intersection-of-two-json-arrays-using-jq | how to get the intersection of two JSON arrays using jq | mwag | peak | 38,365,155 | 12 | true |
so-38779732 | Extract the key-value pairs from the 'apps' object as tab-separated strings. | jq -r '.apps | to_entries[] | "\(.key)\t\(.value)"' | {"apps": {"firefox": "1.0.0", "ie": "1.0.1", "chrome": "2.0.0"}} | firefox 1.0.0
ie 1.0.1
chrome 2.0.0
| {"apps": {"app1": "v1", "app2": "v2"}} | app1 v1
app2 v2
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38779732/running-bash-commands-for-each-json-item-through-jq | Running bash commands for each JSON item through jq | solemnify | Jeff Mercado | 38,779,788 | 14 | true |
so-39204158 | For each object in the Volumes array, extract the VolumeId and the Value of the first Tag, separated by a space. | jq -r '.Volumes[] | .VolumeId + " " + .Tags[0].Value' | {
"Volumes": [
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-system",
"Key": "Name"
}
],
"VolumeId": "vol-00112233"
},
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-swap"... | vol-00112233 vol-rescue-system
vol-00112234 vol-rescue-swap
vol-00112235 vol-rescue-storage
| {
"Volumes": [
{
"AvailabilityZone": "eu-west-1b",
"Tags": [
{
"Value": "data-vol-1",
"Key": "Name"
}
],
"VolumeId": "vol-abc123"
},
{
"AvailabilityZone": "eu-west-1b",
"Tags": [
{
"Value": "data-vol-2",
"K... | vol-abc123 data-vol-1
vol-def456 data-vol-2
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/39204158/loop-through-json-using-jq-to-get-multiple-value | Loop through json using jq to get multiple value | sylye | Andreas Louv | 39,204,803 | 14 | true |
so-39232060 | Extract the row objects from the first result's data array in the JSON input, outputting each row object on a separate line as compact JSON. | jq -c '.results[0].data[].row[]' | {"results":[{"columns":["n"],"data":[{"row":[{"key1":"row1","key2":"row1"}],"meta":[{"key":"value"}]},{"row":[{"key1":"row2","key2":"row2"}],"meta":[{"key":"value"}]}]}],"errors":[]} | {"key1":"row1","key2":"row1"}
{"key1":"row2","key2":"row2"}
| {"results":[{"columns":["id","name"],"data":[{"row":[{"id":1,"name":"Alice"}],"meta":[]},{"row":[{"id":2,"name":"Bob"}],"meta":[]}]}],"errors":[]} | {"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/39232060/process-large-json-stream-with-jq | Process large JSON stream with jq | Martin Preusse | peak | 39,234,104 | 13 | true |
so-39971324 | Select all objects from the 'Subnets' array that contain a tag with Key 'Name' and Value 'TheName'. | jq '.Subnets[] | select(any(.Tags[]; .Key == "Name" and .Value == "TheName"))' | {"Subnets": [{"VpcId": "vpc-1", "SubnetId": "subnet-1", "Tags": [{"Key": "Ignore", "Value": "TheName"}, {"Key": "Name", "Value": "Other"}]}, {"VpcId": "vpc-2", "SubnetId": "subnet-2", "Tags": [{"Key": "Ignore", "Value": "ignore"}, {"Key": "Name", "Value": "TheName"}]}]} | {
"VpcId": "vpc-2",
"SubnetId": "subnet-2",
"Tags": [
{
"Key": "Ignore",
"Value": "ignore"
},
{
"Key": "Name",
"Value": "TheName"
}
]
}
| {"Subnets": [{"VpcId": "vpc-A", "SubnetId": "subnet-A", "Tags": [{"Key": "Name", "Value": "TheName"}]}, {"VpcId": "vpc-B", "SubnetId": "subnet-B", "Tags": [{"Key": "Name", "Value": "Wrong"}]}]} | {
"VpcId": "vpc-A",
"SubnetId": "subnet-A",
"Tags": [
{
"Key": "Name",
"Value": "TheName"
}
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/39971324/using-jq-to-select-a-parent-by-searching-child-key-value-pair | Using jq to select a parent by searching child key/value pair | Tim Smith | peak | 39,971,841 | 13 | true |
so-41045659 | Given a JSON object with two arrays, one at 'time.startPeriodName' and one at 'data.weather', merge them into a single object where the period names are keys and the weather descriptions are values. | jq '[.time.startPeriodName, .data.weather] | transpose | map({(.[0]): .[1]}) | add' | {"time":{"startPeriodName":["Today","Tonight"]},"data":{"weather":["Mostly Sunny","Mostly Cloudy"]}} | {
"Today": "Mostly Sunny",
"Tonight": "Mostly Cloudy"
}
| {"time":{"startPeriodName":["Monday","Tuesday"]},"data":{"weather":["Rain","Sun"]}} | {
"Monday": "Rain",
"Tuesday": "Sun"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/41045659/merge-two-arrays-into-a-single-object-with-jq | Merge two arrays into a single object with jq | Scott | peak | 41,046,715 | 15 | true |
so-42299905 | Flatten an arbitrary JSON object into a single-level object where keys are the dot-separated paths to leaf values and values are the corresponding leaf values. Use '.' as the delimiter. | jq 'reduce (tostream | select(length == 2)) as $i ({}; .[[$i[0][] | tostring] | join(".")] = $i[1])' | {"a":{"b":[1]},"x":[{"y":2},{"z":3}]}
| {
"a.b.0": 1,
"x.0.y": 2,
"x.1.z": 3
}
| {"a":{"b":["p q r"]},"w":[{"x":null},{"y":false},{"z":3}]}
| {
"a.b.0": "p q r",
"w.0.x": null,
"w.1.y": false,
"w.2.z": 3
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42299905/using-jq-flatten-arbitrary-json-to-delimiter-separated-flat-dictionary | Using jq, Flatten Arbitrary JSON to Delimiter-Separated Flat Dictionary | Steve Amerige | Jeff Mercado | 42,303,836 | 11 | true |
so-42635140 | Recursively delete all keys from the JSON object that match the pattern 'temp' (case-insensitive). | jq 'walk(if type == "object" then with_entries(select(.key | test("temp"; "i") | not)) else . end)' | {"name": "root", "tempFile": "delete_me", "nested": {"keep": "safe", "TempVar": "delete_me_too", "deep": {"anotherTemp": "gone"}}} | {
"name": "root",
"nested": {
"keep": "safe",
"deep": {}
}
}
| {"config": {"temporary": true, "valid": false}, "list": [{"item": "ok", "tempId": 123}]} | {
"config": {
"valid": false
},
"list": [
{
"item": "ok"
}
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42635140/jq-recursively-delete-all-keys-that-match-a-given-pattern | Jq: recursively delete all keys that match a given pattern | Kshitiz Sharma | peak | 42,636,398 | 13 | true |
so-43595121 | Extract the final segment of the 'id' string found within the nested 'networkInterfaces' array for each object in the input array. | jq -r '.[].networkProfile.networkInterfaces[].id | sub(".*/";"")' | [{"id":"/subs/blah/vms/A10VM","networkProfile":{"networkInterfaces":[{"id":"/subs/blah/nics/A10NIC-data","resourceGroup":"RG1"}]}}] | A10NIC-data
| [{"id":"/sub/rg/vm/MyVM","networkProfile":{"networkInterfaces":[{"id":"/sub/rg/nic/MyNic-01","resourceGroup":"RG2"},{"id":"/sub/rg/nic/MyNic-02","resourceGroup":"RG2"}]}}] | MyNic-01
MyNic-02
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/43595121/linux-cli-how-to-get-substring-from-json-jq-grep | Linux CLI - How to get substring from JSON jq + grep? | Adoyt | peak | 43,595,321 | 11 | true |
so-44032450 | Extract the 'password' and 'username' values from the 'data' object in a JSON structure. | jq '.data.password, .data.username' | {
"request_id": "9a081c0c-9401-7eca-f55d-50e3b7c0301c",
"lease_id": "",
"renewable": false,
"lease_duration": 2764800,
"data": {
"password": "test123",
"username": "testuser1"
},
"wrap_info": null,
"warnings": null,
"auth": null
} | "test123"
"testuser1"
| {
"data": {
"password": "secret_pass",
"username": "admin_user"
}
} | "secret_pass"
"admin_user"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/44032450/parse-through-json-using-only-bash | Parse through JSON using only Bash | user4889345 | grundic | 44,032,543 | 11 | true |
so-45548604 | Select the 3rd-to-last and 4th-to-last elements from a JSON array and return them as a new array in that order. | jq '[.[-3], .[-4]]' | [
{"foo": "bar", "foo2": "bar2"},
{"foo3": "bar3", "foo4": "bar4"},
{"foo5": "bar5", "foo6": "bar6"},
{"foo7": "bar7", "foo8": "bar8"},
{"foo9": "bar9", "foo10": "bar10"}
] | [
{
"foo5": "bar5",
"foo6": "bar6"
},
{
"foo3": "bar3",
"foo4": "bar4"
}
]
| [
{"a": 1},
{"b": 2},
{"c": 3},
{"d": 4},
{"e": 5},
{"f": 6}
] | [
{
"d": 4
},
{
"c": 3
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/45548604/jq-select-range | jq: Select range | Alex | peak | 45,549,004 | 14 | true |
so-46397592 | Remove duplicate objects from the 'Result' array based on unique combinations of 'name' and 'id', keeping the first occurrence of each combination. | jq '.Result |= unique_by({name, id})' | {"Result":[{"name":"validation-of-art","id":"12","status":"passed","duration":4740302},{"name":"validation-of-art","id":"12","status":"passed","duration":272320},{"name":"validation-of-art","id":"13","status":"passed","duration":272320}]} | {
"Result": [
{
"name": "validation-of-art",
"id": "12",
"status": "passed",
"duration": 4740302
},
{
"name": "validation-of-art",
"id": "13",
"status": "passed",
"duration": 272320
}
]
}
| {"Result":[{"name":"test-a","id":"1","val":1},{"name":"test-a","id":"1","val":2},{"name":"test-b","id":"2","val":3}]} | {
"Result": [
{
"name": "test-a",
"id": "1",
"val": 1
},
{
"name": "test-b",
"id": "2",
"val": 3
}
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/46397592/jq-removing-duplicates-using-unique-by | JQ - removing duplicates using unique_by | Saurabh | jq170727 | 46,397,650 | 11 | true |
so-47371280 | Recursively delete all keys named 'publicAccess' or 'userGroupAccesses' from the JSON object. | jq 'del(.. | .publicAccess?, .userGroupAccesses?)' | {"data": [{"name": "Test", "program": {"publicAccess": "--------", "externalAccess": false, "userGroupAccesses": [{"access": "r-------"}, {"access": "rw------"}], "id": "MmBqeMLIC2r"}, "publicAccess": "rw------"}]} | {
"data": [
{
"name": "Test",
"program": {
"externalAccess": false,
"id": "MmBqeMLIC2r"
}
}
]
}
| {"data": [{"name": "Item", "program": {"publicAccess": "x", "internal": true, "userGroupAccesses": [], "code": 123}, "publicAccess": "y"}, {"simple": "value"}]} | {
"data": [
{
"name": "Item",
"program": {
"internal": true,
"code": 123
}
},
{
"simple": "value"
}
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/47371280/delete-objects-and-arrays-with-jq-which-match-a-key | Delete objects and arrays with jq which match a key | dh762 | jq170727 | 47,371,754 | 17 | true |
so-47551333 | Convert a JSON array of objects containing 'tone_id' and 'score' fields into a single object where keys are the 'tone_id' values and values are the corresponding 'score' values. | jq 'map({(.tone_id): .score}) | add' | [
{"tone_id": "anger", "score": 0.012, "tone_name": "Anger"},
{"tone_id": "disgust", "score": 0.002, "tone_name": "Disgust"},
{"tone_id": "fear", "score": 0.14, "tone_name": "Fear"},
{"tone_id": "joy", "score": 0.42, "tone_name": "Joy"}
] | {
"anger": 0.012,
"disgust": 0.002,
"fear": 0.14,
"joy": 0.42
}
| [
{"tone_id": "sadness", "score": 0.5, "tone_name": "Sadness"},
{"tone_id": "joy", "score": 0.5, "tone_name": "Joy"}
] | {
"sadness": 0.5,
"joy": 0.5
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/47551333/jq-convert-a-list-of-objects-into-a-summarized-object | jq - convert a list of objects into a summarized object | munikarmanish | peak | 47,553,076 | 11 | true |
so-48005870 | Extract the id, name, and create date from each object within the newList dictionary, outputting them as space-separated values on separate lines. | jq -r '.newList[] | "\(.id) \(.name) \(.create.date)"' | {"newList": {"243": {"id": "243", "name": "test", "create": {"date": "2017-08-31 13:57:29"}}, "244": {"id": "244", "name": "example", "create": {"date": "2017-09-01 10:00:00"}}}} | 243 test 2017-08-31 13:57:29
244 example 2017-09-01 10:00:00
| {"newList": {"100": {"id": "100", "name": "alpha", "create": {"date": "2020-01-01 00:00:00"}}, "101": {"id": "101", "name": "beta", "create": {"date": "2020-01-02 12:30:00"}}}} | 100 alpha 2020-01-01 00:00:00
101 beta 2020-01-02 12:30:00
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/48005870/iterate-over-json-with-jq | Iterate over json with jq | SnIpY | Inian | 48,006,169 | 13 | true |
so-48904371 | Extract the value of the 'type' field for every root-level key that ends with a slash '/'. Output each value on a separate line. | jq -r '. as $o | keys_unsorted[] | select(endswith("/")) | $o[.].type' | {"token/": {"accessor": "auth_token_909d6a81", "type": "token"}, "userpass/": {"description": "", "type": "userpass"}, "request_id": "f2a4c135", "data": {"more_data": "snipped"}} | token
userpass
| {"ldap/": {"url": "ldap://example.com", "type": "ldap"}, "okta/": {"org_url": "https://example.okta.com", "type": "okta"}, "meta": {"status": "ok"}} | ldap
okta
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/48904371/jq-filter-input-based-on-if-key-ends-with-specified-string | jq: filter input based on if key ends with specified string | ssc | RomanPerekhrest | 48,904,944 | 16 | true |
so-49200066 | Given a JSON array of objects representing GitLab groups, filter out objects where 'parent_id' is null, sort the remaining objects by 'parent_id', and output the 'name' and 'parent_id' of each object as tab-separated values. | jq -r 'map(select(.parent_id != null)) | sort_by(.parent_id)[] | [.name, .parent_id] | @tsv' | [{"id":10,"name":"another-test","parent_id":9},{"id":11,"name":"asdfg","parent_id":7},{"id":12,"name":"no-parent","parent_id":null}] | asdfg 7
another-test 9
| [{"id":1,"name":"GroupC","parent_id":3},{"id":2,"name":"GroupA","parent_id":1},{"id":3,"name":"GroupB","parent_id":null}] | GroupA 1
GroupC 3
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/49200066/jq-select-and-sort-by | jq select() and sort_by() | Bruno9779 | RomanPerekhrest | 49,200,556 | 15 | true |
so-49228126 | Convert each JSON object in the input stream into a CSV row, preserving the order of values as they appear in the object. | jq -r '[.[]] | @csv' | {"ClientCountry":"ca","ClientASN":812,"CacheResponseStatus":404,"CacheResponseBytes":130756,"CacheCacheStatus":"hit"}
{"ClientCountry":"ua","ClientASN":206996,"CacheResponseStatus":301,"CacheResponseBytes":142,"CacheCacheStatus":"unknown"} | "ca",812,404,130756,"hit"
"ua",206996,301,142,"unknown"
| {"ClientCountry":"de","ClientASN":123,"CacheResponseStatus":200,"CacheResponseBytes":500,"CacheCacheStatus":"miss"}
{"ClientCountry":"fr","ClientASN":456,"CacheResponseStatus":500,"CacheResponseBytes":0,"CacheCacheStatus":"error"} | "de",123,200,500,"miss"
"fr",456,500,0,"error"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/49228126/how-to-convert-json-into-csv-file-using-jq | How to convert json into csv file using jq? | Palanikumar | peak | 49,228,411 | 12 | true |
so-49342129 | Transform a JSON array of commit objects into a single JSON object with a key "Commits" containing an array of objects, each having "message" and "name" fields extracted from the nested commit structure. | jq '{Commits: [.[] | {message: .commit.message, name: .commit.committer.name}]}' | [
{
"commit": {
"message": "Merge pull request #162",
"committer": {
"name": "Stephen Dolan"
}
}
},
{
"commit": {
"message": "Reject all overlong UTF8 sequences.",
"committer": {
"name": "Stephen Dolan"
}
}
}
] | {
"Commits": [
{
"message": "Merge pull request #162",
"name": "Stephen Dolan"
},
{
"message": "Reject all overlong UTF8 sequences.",
"name": "Stephen Dolan"
}
]
}
| [
{
"commit": {
"message": "Fix bug in parser",
"committer": {
"name": "Jane Doe"
}
}
},
{
"commit": {
"message": "Update documentation",
"committer": {
"name": "John Smith"
}
}
},
{
"commit": {
"message": "Refactor core module",
... | {
"Commits": [
{
"message": "Fix bug in parser",
"name": "Jane Doe"
},
{
"message": "Update documentation",
"name": "John Smith"
},
{
"message": "Refactor core module",
"name": "Alice Johnson"
}
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/49342129/jq-to-output-results-as-json | jq to output results as JSON | xpt | peak | 49,342,492 | 15 | true |
so-50255694 | Given a JSON array of strings, filter out any string that starts with an uppercase letter. Return the remaining strings in an array. | jq '[.[] | select(test("^[A-Z]") | not)]' | ["Dog", "cat", "Bird"] | [
"cat"
]
| ["Apple", "banana", "Cherry", "date"] | [
"banana",
"date"
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/50255694/jq-negative-select-elements-of-array | jq negative select elements of array | Konrads | peak | 50,255,988 | 14 | true |
so-50741593 | Sort the items in each object of the input array by their lastTimestamp field in ascending order. | jq '.[].items |= sort_by(.lastTimestamp)' | [
{
"apiVersion": "v1",
"items": [
{
"lastTimestamp": "2018-06-07T16:02:52Z",
"name": "event-b"
},
{
"lastTimestamp": "2018-06-07T11:59:53Z",
"name": "event-a"
}
]
}
] | [
{
"apiVersion": "v1",
"items": [
{
"lastTimestamp": "2018-06-07T11:59:53Z",
"name": "event-a"
},
{
"lastTimestamp": "2018-06-07T16:02:52Z",
"name": "event-b"
}
]
}
]
| [
{
"apiVersion": "v1",
"items": [
{
"lastTimestamp": "2018-06-08T10:00:00Z",
"name": "z-event"
},
{
"lastTimestamp": "2018-06-07T09:00:00Z",
"name": "a-event"
},
{
"lastTimestamp": "2018-06-07T12:00:00Z",
"name": "m-event"
}
... | [
{
"apiVersion": "v1",
"items": [
{
"lastTimestamp": "2018-06-07T09:00:00Z",
"name": "a-event"
},
{
"lastTimestamp": "2018-06-07T12:00:00Z",
"name": "m-event"
},
{
"lastTimestamp": "2018-06-08T10:00:00Z",
"name": "z-event"
}
... | real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/50741593/how-can-i-use-jq-to-sort-by-datetime-field | How can I use jq to sort by datetime field? | Chris Stryczynski | RomanPerekhrest | 50,742,286 | 17 | true |
so-51147753 | Add the keys 'x3' with value 'x3Val' and 'x4' with value 'x4Val' to the object located at key 'x'. | jq '.x += {"x3": "x3Val", "x4": "x4Val"}' | {"a": "aVal", "x": {"x1": "x1Val", "x2": "x2Val"}, "y": {"y1": "y1Val"}} | {
"a": "aVal",
"x": {
"x1": "x1Val",
"x2": "x2Val",
"x3": "x3Val",
"x4": "x4Val"
},
"y": {
"y1": "y1Val"
}
}
| {"a": "test", "x": {"x1": "1"}, "y": {}} | {
"a": "test",
"x": {
"x1": "1",
"x3": "x3Val",
"x4": "x4Val"
},
"y": {}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/51147753/append-json-objects-using-jq | Append JSON Objects using jq | theapache64 | RomanPerekhrest | 51,148,168 | 10 | true |
so-51869431 | Filter an object to keep only the key-value pairs where the key contains the string "VMIMAGE", preserving the original keys. | jq 'with_entries( select(.key | contains("VMIMAGE")) )' | {
"CP-COMPUTEENGINE-VMIMAGE-F1-MICRO": "value1",
"CP-COMPUTEENGINE-VMIMAGE-N1-STANDARD-1": "value2",
"OTHER-KEY": "value3",
"ANOTHER-KEY": "value4"
} | {
"CP-COMPUTEENGINE-VMIMAGE-F1-MICRO": "value1",
"CP-COMPUTEENGINE-VMIMAGE-N1-STANDARD-1": "value2"
}
| {
"AWS-VMIMAGE-T2-MICRO": "aws-val1",
"AZURE-VMIMAGE-B1S": "azure-val1",
"CP-COMPUTEENGINE-VMIMAGE-G1-SMALL": "gcp-val1",
"DATABASE-URL": "db-val",
"API-KEY": "secret"
} | {
"AWS-VMIMAGE-T2-MICRO": "aws-val1",
"AZURE-VMIMAGE-B1S": "azure-val1",
"CP-COMPUTEENGINE-VMIMAGE-G1-SMALL": "gcp-val1"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/51869431/using-jq-select-elements-with-keys-containing-some-string-key-preserved-in-resu | Using jq select elements with keys containing some string, key preserved in results | Mzq | peak | 51,870,918 | 15 | true |
so-53473584 | Convert the 'lotsize' field to acres by dividing by 43560, and convert the 'dateSold' Unix timestamp to a formatted date string 'Day Month DD, YYYY'. Output the result as a compact JSON object with keys 'acres' and 'soldOn'. | jq -c '{acres: (.lotsize/43560), soldOn: (.dateSold | strftime("%A %B %d, %Y")) }' | {"lotsize": 65340, "dateSold": 1207897200} | {"acres":1.5,"soldOn":"Friday April 11, 2008"}
| {"lotsize": 43560, "dateSold": 1609459200} | {"acres":1,"soldOn":"Friday January 01, 2021"}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/53473584/jq-and-math-functions | jq and Math functions | richb-hanover | peak | 53,474,079 | 18 | true |
so-54489648 | Given a JSON array of objects with 'createdAt' and 'platform' fields, find the maximum 'createdAt' value among objects where 'platform' is 'foo'. | jq '[.[] | select(.platform == "foo") | .createdAt] | max' | [
{"createdAt": 1548729542000, "platform": "foo"},
{"createdAt": 1548759398000, "platform": "foo"},
{"createdAt": 1548912360000, "platform": "foo"},
{"createdAt": 1548904550000, "platform": "bar"}
] | 1548912360000
| [
{"createdAt": 100, "platform": "foo"},
{"createdAt": 200, "platform": "bar"},
{"createdAt": 300, "platform": "foo"}
] | 300
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/54489648/how-to-get-max-value-from-json | How to get max value from JSON? | zhuguowei | oguz ismail | 54,489,836 | 11 | true |
so-55027717 | Recursively search a JSON structure for any key named 'name' and output all non-null values found associated with that key. | jq '.. | .name? | select(. != null)' | {"file":{"id":"123456789","name":"137.txt"},"lines":219,"characters":2456}
| "137.txt"
| {"user":{"profile":{"name":"Alice"}},"settings":{"theme":"dark"},"items":[{"name":"Item1"},{"id":2}]}
| "Alice"
"Item1"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/55027717/jq-accessing-element-no-matter-how-many-levels-deep | JQ: accessing element no matter how many levels deep | Olaf | Inian | 55,028,089 | 11 | true |
so-56690455 | From a JSON object containing a 'certificates' array, select the certificate objects where 'variable_path' is not null and contains the string 'thing'. | jq '.certificates[] | select(.variable_path | strings | test("thing"))' | {
"certificates": [
{
"configurable": false,
"property_reference": ".properties.director_ssl",
"property_type": "rsa_cert_credentials",
"product_guid": "p-blah-29d4678e926cf2069871",
"location": "ops_manager",
"variable_path": null,
"issuer": "/C=US/O=Blah",
"valid_... | {
"configurable": false,
"property_reference": ".properties.blobstore_certificate",
"property_type": "rsa_cert_credentials",
"product_guid": "p-blah-29d4678e926cf2069871",
"location": "ops_manager",
"variable_path": "something",
"issuer": "/C=US/O=Blah",
"valid_from": "2019-01-16T19:55:11Z",
"valid_un... | {
"certificates": [
{
"variable_path": null
},
{
"variable_path": "nothing_here"
},
{
"variable_path": "my_thing_value"
}
]
} | {
"variable_path": "nothing_here"
}
{
"variable_path": "my_thing_value"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/56690455/jq-select-objects-where-value-contains-string-and-value-not-null | JQ Select Objects Where Value Contains String And Value Not Null | Radford | peak | 56,690,698 | 11 | true |
so-56909701 | Given a stream of JSON objects (JSON Lines), extract the 'email' and 'time' fields from each object, ignoring any objects where 'email' is missing or null. Aggregate the results into a single JSON array. | jq -s '[.[] | select(.email) | {email, time}]' | {"name":"myname", "environment":"staging", "email":"email1@example.com", "time":"2017-04-02T05:00:00.046Z"}
{"name":"myname", "environment":"staging", "email":"email2@example.com", "time":"2017-02-02T05:00:00.046Z"}
{"name":"myothername", "environment":"staging", "time":"2017-10-02T05:00:00.046Z"} | [
{
"email": "email1@example.com",
"time": "2017-04-02T05:00:00.046Z"
},
{
"email": "email2@example.com",
"time": "2017-02-02T05:00:00.046Z"
}
]
| {"email":"user@test.com", "time":"2023-01-01T00:00:00Z"}
{"time":"2023-01-02T00:00:00Z"}
{"email":"admin@test.com", "time":"2023-01-03T00:00:00Z"} | [
{
"email": "user@test.com",
"time": "2023-01-01T00:00:00Z"
},
{
"email": "admin@test.com",
"time": "2023-01-03T00:00:00Z"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/56909701/aggregate-the-results-of-a-jq-query-into-a-single-array | Aggregate the results of a jq query into a single array | Acapulco | peak | 56,910,388 | 14 | true |
so-57649735 | Transform the input JSON by renaming 'temperature' to 'temp', 'humidity' to 'hum', and extracting the numeric ID following 'ID ' in the 'message' field into an 'id' field. | jq '{temp: .temperature, hum: .humidity, id: (.message | capture("ID (?<id>[[:digit:]]+)").id)}' | {"temperature":"21", "humidity":"12.3", "message":"Today ID 342 is running"} | {
"temp": "21",
"hum": "12.3",
"id": "342"
}
| {"temperature":"10", "humidity":"50.0", "message":"Sensor ID 99 detected"} | {
"temp": "10",
"hum": "50.0",
"id": "99"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/57649735/how-to-extract-a-json-value-substring-with-jq | How to extract a json value substring with jq | alcor | Charles Duffy | 57,649,785 | 13 | true |
so-58566524 | Given a JSON object containing an array of repository objects under the key 'values', where each object has a 'name' and a 'links' object with a 'clone' array, output each HTTP clone URL followed by a space and the repository name on separate lines. Filter the clone links to only include those where the 'name' field is... | jq -r '.values[] | (.links.clone[] | select(.name=="http") | .href) + " " + .name' | {"values":[{"name":"GitRepository1","links":{"clone":[{"name":"http","href":"http://bitbucketlocalserver:7990/scm/PROJECT_NAME/gitrepo1.git"},{"name":"ssh","href":"ssh://git@bitbucketlocalserver:7990/PROJECT_NAME/gitrepo1.git"}]}},{"name":"GitRepository2","links":{"clone":[{"name":"http","href":"http://bitbucketlocalse... | http://bitbucketlocalserver:7990/scm/PROJECT_NAME/gitrepo1.git GitRepository1
http://bitbucketlocalserver:7990/scm/PROJECT_NAME/gitrepo2.git GitRepository2
| {"values":[{"name":"RepoA","links":{"clone":[{"name":"http","href":"http://example.com/repoA.git"}]}},{"name":"RepoB","links":{"clone":[{"name":"ssh","href":"ssh://example.com/repoB.git"},{"name":"http","href":"http://example.com/repoB.git"}]}}]} | http://example.com/repoA.git RepoA
http://example.com/repoB.git RepoB
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/58566524/jq-how-to-define-filter-to-remove-brackets-quotes-and-commas-from-output-arra | JQ - How to define filter to remove brackets, quotes and commas from output array | adbdkb | peak | 58,567,559 | 15 | true |
so-60350315 | Format the 'filename', 'format_name', and 'tags.album_artist' fields from the input JSON into a single comma-separated line without surrounding quotes or CSV escaping. | jq -r '[.format.filename,.format.format_name,.format.tags.album_artist] | join(",")' | {"format":{"filename":"01 Jubilee.flac","format_name":"flac","tags":{"album_artist":"Bill Charlap Trio"}}} | 01 Jubilee.flac,flac,Bill Charlap Trio
| {"format":{"filename":"song.mp3","format_name":"mp3","tags":{"album_artist":"Artist Name"}}} | song.mp3,mp3,Artist Name
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/60350315/why-does-the-jq-raw-output-argument-fail-to-remove-quotes-from-csv-output | Why does the jq --raw-output argument fail to remove quotes from @csv output? | user5395338 | pii_ke | 62,903,250 | 11 | true |
so-61396735 | Decode all base64-encoded values within the 'data' object, leaving the rest of the JSON structure unchanged. Output only the decoded 'data' object. | jq '.data | map_values(@base64d)' | {"someattribute": "somevalue", "data": {"SOMENAME": "SGVsbG8=", "SOMEOTHERNAME": "V29ybGQ="}} | {
"SOMENAME": "Hello",
"SOMEOTHERNAME": "World"
}
| {"id": 1, "data": {"KEY1": "YQ==", "KEY2": "Yg=="}} | {
"KEY1": "a",
"KEY2": "b"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/61396735/transform-json-object-with-jq-transforming-values-with-base64-decode | Transform json object with jq, transforming values with base64 decode | David M. Karr | Steve | 71,600,771 | 10 | true |
so-61492210 | Convert the entire input JSON object into a single JSON-encoded string. | jq -c 'tostring' | {"region": "CA", "waf_rule_tags": "{\"RULEID:942100\":[\"application-multi\"]}"} | "{\"region\":\"CA\",\"waf_rule_tags\":\"{\\\"RULEID:942100\\\":[\\\"application-multi\\\"]}\"}"
| {"name": "test", "data": "{\"key\": \"value\"}"} | "{\"name\":\"test\",\"data\":\"{\\\"key\\\": \\\"value\\\"}\"}"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/61492210/how-to-stringify-json-using-jq | How to stringify JSON using JQ | Alex Cohen | peak | 61,492,758 | 13 | true |
so-63319824 | Filter JSON objects where the 'column3' field starts with 'ab', then output the values of 'column1', 'column2', and 'column3' as a CSV row. | jq -r 'select(.column3 | startswith("ab")) | [.column1, .column2, .column3] | @csv' | {"column1": "hello", "column2": "bye", "column3": "abc"}
{"column1": "world", "column2": "hi", "column3": "xyz"} | "hello","bye","abc"
| {"column1": "test1", "column2": "test2", "column3": "ab_test"}
{"column1": "test3", "column2": "test4", "column3": "no_match"} | "test1","test2","ab_test"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/63319824/how-to-add-contains-or-startswith-in-jq | How to add contains or startswith in jq | artemisia480 | Shawn | 63,320,808 | 10 | true |
so-65728085 | Sort a JSON array of objects by their 'TagVersion' field in ascending order, treating the version strings as semantic versions (e.g., 1.0.9 comes before 1.0.10). | jq 'sort_by(.TagVersion | split(".") | map(tonumber))' | [
{"TagVersion": "1.0.11"},
{"TagVersion": "1.1.8"},
{"TagVersion": "1.0.10"},
{"TagVersion": "1.0.9"},
{"TagVersion": "1.0.77"}
] | [
{
"TagVersion": "1.0.9"
},
{
"TagVersion": "1.0.10"
},
{
"TagVersion": "1.0.11"
},
{
"TagVersion": "1.0.77"
},
{
"TagVersion": "1.1.8"
}
]
| [
{"TagVersion": "2.0.0"},
{"TagVersion": "1.9.9"},
{"TagVersion": "1.10.0"}
] | [
{
"TagVersion": "1.9.9"
},
{
"TagVersion": "1.10.0"
},
{
"TagVersion": "2.0.0"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/65728085/jq-sort-by-version-as-string | jq sort by version as string | brcebn | Amadan | 65,728,139 | 10 | true |
so-70492898 | From a JSON object containing a 'fruits' array of objects with 'version' and 'price' fields, find the fruit with the highest version number and return its price. | jq '.fruits | sort_by(-.version)[0].price' | {"fruits":[{"name":"banana","color":"yellow","price":0.51,"version":1},{"name":"banana","color":"yellow","price":0.52,"version":2}]}
| 0.52
| {"fruits":[{"name":"apple","color":"red","price":1.0,"version":3},{"name":"apple","color":"green","price":1.2,"version":1},{"name":"orange","color":"orange","price":0.8,"version":2}]}
| 1
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/70492898/using-jq-how-to-sort-array-of-object | using jq how to sort array of object | kumar | jpseng | 70,493,529 | 11 | true |
so-70628716 | For each item in the items array, if any container status has a waiting or terminated state, output the namespace, name, and the reason from either the waiting or terminated state (preferring waiting if both exist, though typically only one exists) as CSV. | jq -r '.items[] | select(any(.status.containerStatuses[]; .state.waiting or .state.terminated)) | [.metadata.namespace, .metadata.name, (.status.containerStatuses[].state | (.waiting.reason // .terminated.reason))] | @csv' | {"items": [{"metadata": {"namespace": "default", "name": "pod-1"}, "status": {"containerStatuses": [{"state": {"waiting": {"reason": "CrashLoopBackOff"}}}]}}, {"metadata": {"namespace": "kube-system", "name": "pod-2"}, "status": {"containerStatuses": [{"state": {"terminated": {"reason": "Error"}}}]}}]} | "default","pod-1","CrashLoopBackOff"
"kube-system","pod-2","Error"
| {"items": [{"metadata": {"namespace": "prod", "name": "web-1"}, "status": {"containerStatuses": [{"state": {"waiting": {"reason": "ImagePullBackOff"}}}]}}, {"metadata": {"namespace": "dev", "name": "api-1"}, "status": {"containerStatuses": [{"state": {"terminated": {"reason": "OOMKilled"}}}]}}]} | "prod","web-1","ImagePullBackOff"
"dev","api-1","OOMKilled"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/70628716/print-from-jq-using-a-wild-card-or-coalesce-to-first-non-null | Print from jq using a wild card (or coalesce to first non null) | Vaccano | peak | 70,629,425 | 13 | true |
so-72277908 | Sort an array of objects by the 'title' field in a case-insensitive manner. | jq 'sort_by(.title | ascii_downcase)' | [{"title": "first", "description": "foo"}, {"title": "Second", "description": "bar"}] | [
{
"title": "first",
"description": "foo"
},
{
"title": "Second",
"description": "bar"
}
]
| [{"title": "Banana", "val": 1}, {"title": "apple", "val": 2}, {"title": "Cherry", "val": 3}] | [
{
"title": "apple",
"val": 2
},
{
"title": "Banana",
"val": 1
},
{
"title": "Cherry",
"val": 3
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/72277908/how-to-sort-case-insensitive-using-jq | how to sort case insensitive using jq | Mikhail Tokarev | Mikhail Tokarev | 72,277,909 | 10 | true |
so-74152553 | Round the input number to two decimal places. | jq '.*100|round/100' | 20.152 | 20.15
| 3.14159 | 3.14
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/74152553/jq-round-number-to-two-decimal-places | JQ round number to two decimal places | Lucia | knittl | 74,152,813 | 16 | true |
Jqweave Frozen Questions
A held-out natural-language-to-jq evaluation set derived from highly voted Stack Overflow questions and accepted answers. It tests whether Jqweave generalizes beyond the phrasing and task distribution of its synthetic training data.
Contents
- 49 manually reviewed tasks from 49 unique source questions.
- Two different representative inputs per task, with actual outputs from both.
- Every task is in the
testsplit; no paraphrases or training rows are included. - Zero input-text or request/command overlap with
asterbraid/jqweave-data.
Every reference command was executed on both inputs with jq-1.6: 98 successful executions, 0 errors. Commands start with jq, read one JSON stream on stdin, and avoid filenames, modules, environment access, additional inputs, and shell execution.
Source and attribution
Each row includes question_url, question_title, question_owner, answer_owner, and answer_id. ATTRIBUTION.md lists every source. The request is a self-contained instruction derived from the question and accepted answer; command is an executable solution. Request-to-command intent was manually reviewed in addition to execution verification.
from datasets import load_dataset
ds = load_dataset("asterbraid/jqweave-frozen-data", split="test")
print(ds[0])
Public model evaluation
Greedy generation with public Jqweave models, one prediction per task. Valid means the generated command executes. Correct requires exact expected output on both inputs, with only trailing special tokens removed.
| Model | Valid | Correct |
|---|---|---|
| Jqweave 0.5B | 44.9% (22/49) | 6.1% (3/49) |
| Jqweave 1.5B | 44.9% (22/49) | 6.1% (3/49) |
| Jqweave 1.5B Real | 46.9% (23/49) | 20.4% (10/49) |
| Jqweave 1.5B Real v2 | 59.2% (29/49) | 28.6% (14/49) |
| Jqweave 3B Real | 67.3% (33/49) | 36.7% (18/49) |
| Jqweave 7B Real | 77.6% (38/49) | 53.1% (26/49) |
Full predictions and summaries are included under evaluation/.
Limitations
This is a small, high-vote sample, not a representative benchmark of all jq use. Tasks were selected for compatibility with single-stream input and the safety guard. Exact outputs on two synthetic representative inputs do not prove correctness on every possible input. Some requests or commands may be ambiguous outside their original context.
License
Original Stack Overflow content and these derived rows are CC BY-SA 4.0. See SO_DATASET_LICENSE.txt and ATTRIBUTION.md. Included collection, conversion, review, and validation code is Apache-2.0.
- Downloads last month
- 18