Datasets:
id stringlengths 10 11 | request stringlengths 54 212 | command stringlengths 6 185 | input_text stringlengths 15 367 | expected_output stringlengths 2 692 | validation_input stringlengths 17 358 | validation_output stringlengths 2 438 | family stringclasses 1
value | difficulty int64 3 3 | split stringclasses 1
value | source stringclasses 1
value | license stringclasses 1
value | question_url stringlengths 66 125 | question_title stringlengths 21 97 | question_owner stringlengths 3 18 | answer_owner stringlengths 3 24 | answer_id int64 1.96M 52.1M | question_score int64 39 1.32k | reviewed bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
so-18592173 | From a JSON object where values are objects containing 'name' and 'location', select only those objects where 'location' is 'Stockholm' and output their 'name' values. | jq -r '.[] | select(.location == "Stockholm") | .name' | {"FOO": {"name": "Donald", "location": "Stockholm"}, "BAR": {"name": "Walt", "location": "Stockholm"}, "BAZ": {"name": "Jack", "location": "Whereever"}} | Donald
Walt
| {"A": {"name": "Alice", "location": "Stockholm"}, "B": {"name": "Bob", "location": "London"}} | Alice
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq | Select objects based on value of variable in object using jq | Daniel | Daniel | 18,608,100 | 557 | true |
so-1955505 | Extract the value of the 'text' field from a JSON object. | jq -r '.text' | {"text": "My status", "favorited": false} | My status
| {"text": "Another update", "favorited": true} | Another update
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools | Parsing JSON with Unix tools | auser | Brian Campbell | 1,955,555 | 1,322 | true |
so-19573517 | Select and output only the objects from the input stream where the 'geo' field is not null. | jq 'select(.geo != null)' | {"geo": {"lat": 1.0}}
{"geo": null}
{"geo": {"lat": 2.0}} | {
"geo": {
"lat": 1
}
}
{
"geo": {
"lat": 2
}
}
| {"geo": null}
{"geo": {"lng": 5.0}}
{"geo": null} | {
"geo": {
"lng": 5
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/19573517/jq-conditional-output | jq Conditional output | clwen | max taldykin | 20,489,951 | 120 | true |
so-20181467 | Convert a JSON object with dynamic keys into CSV format, where each line contains the key and value quoted and separated by a comma. | jq -r 'to_entries[] | [.key, .value] | @csv' | {"123":"abc","231":"dbh","452":"xyz"} | "123","abc"
"231","dbh"
"452","xyz"
| {"a":"1","b":"2"} | "a","1"
"b","2"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/20181467/how-to-map-an-object-to-arrays-so-it-can-be-converted-to-csv | How to map an object to arrays so it can be converted to csv? | lsl | Jeff Mercado | 24,254,365 | 54 | true |
so-21334348 | Count the number of items in the top-level JSON array. | jq length | [
{
"cid": 49,
"pyn": "yi4",
"hans": "亿",
"hant": "億",
"tid": 68,
"l10n": "cent million",
"pid": 1,
"pos": "num",
"pos_txt": ""
},
{
"cid": 50,
"pyn": "yi4",
"hans": "亿",
"hant": "億",
"tid": 69,
"l10n": "100 millions",
"pid": 1,
"pos": "num",
... | 2
| [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
] | 3
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/21334348/how-to-count-items-in-json-object-using-command-line | How to count items in JSON object using command line? | Édouard Lopez | Ken | 21,355,442 | 476 | true |
so-23118341 | Extract the keys from the JSON object as a sorted array of strings. | jq keys | {
"email": "madireddy@test.com",
"versionID": "2323",
"context": "test",
"date": "02-03-2014-13:41",
"versionName": "application"
} | [
"context",
"date",
"email",
"versionID",
"versionName"
]
| {
"Created-By": "Apache Maven",
"Build-Number": "",
"Archiver-Version": "Plexus Archiver"
} | [
"Archiver-Version",
"Build-Number",
"Created-By"
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/23118341/how-to-get-key-names-from-json-using-jq | How to get key names from JSON using jq | Ezhilan Mahalingam | anubhava | 23,118,607 | 314 | true |
so-24698188 | Given a JSON array of objects, flatten each object by removing the 'fields' key and promoting its values (taking the first element if they are arrays) to the top level, while preserving other top-level keys. | jq 'map(with_entries(select(.key != "fields")) + (.fields | with_entries(.value = .value[0])))' | [
{
"index": "index1",
"type": "type1",
"id": "id1",
"fields": {
"deviceOs": ["Android"],
"deviceID": ["deviceID1"],
"country": ["DE"]
}
},
{
"index": "index2",
"type": "type2",
"id": "id2",
"fields": {
"deviceOs": ["iOS"],
"deviceID": ["deviceID2"... | [
{
"index": "index1",
"type": "type1",
"id": "id1",
"deviceOs": "Android",
"deviceID": "deviceID1",
"country": "DE"
},
{
"index": "index2",
"type": "type2",
"id": "id2",
"deviceOs": "iOS",
"deviceID": "deviceID2",
"country": "US"
}
]
| [
{
"index": "idx1",
"val": "v1",
"fields": {
"a": ["x"],
"b": ["y"]
}
}
] | [
{
"index": "idx1",
"val": "v1",
"a": "x",
"b": "y"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/24698188/flatten-a-json-document-using-jq | Flatten a JSON document using jq | Dror | Jeff Mercado | 24,710,337 | 39 | true |
so-25378013 | Convert a JSON object into a list of strings where each string is formatted as "key=value". | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' | {
"var": 1,
"foo": "bar",
"x": "test"
} | var=1
foo=bar
x=test
| {
"name": "Alice",
"age": 30,
"active": true
} | name=Alice
age=30
active=true
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/25378013/how-to-convert-a-json-object-to-key-value-format-in-jq | How to convert a JSON object to key=value format in jq? | gianebao | aioobe | 25,378,171 | 75 | true |
so-26701538 | From a JSON array of objects each having an 'Id' string and a 'Names' array of strings, filter out any object where any name in 'Names' contains the substring 'data', and output the 'Id' of the remaining objects. | jq -r '.[] | select(.Names | all(contains("data") | not)) | .Id' | [{"Id": "abc", "Names": ["condescending_jones"]}, {"Id": "def", "Names": ["foo_data"]}] | abc
| [{"Id": "123", "Names": ["jovial_wozniak"]}, {"Id": "456", "Names": ["bar_data"]}, {"Id": "mix", "Names": ["foo_data", "safe"]}] | 123
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/26701538/jq-how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array | jq: how to filter an array of objects based on values in an inner array? | Abe Voelker | Iain Samuel McLean Elder | 26,701,851 | 518 | true |
so-27562424 | For each object in the input array, create a new object containing the top-level id and the value of info-spec from the nested stuff object. | jq '[.[] | {id, "info-spec": .stuff["info-spec"]}]' | [{"id": 12345678, "stuff": {"book": "shelf", "hook": "line", "took": "off", "info-spec": 12}, "votes": 23}, {"id": 12345679, "stuff": {"book": "maker", "hook": "sinker", "took": "pisin", "info-spec": 23}, "votes": 1}] | [
{
"id": 12345678,
"info-spec": 12
},
{
"id": 12345679,
"info-spec": 23
}
]
| [{"id": 999, "stuff": {"info-spec": 100, "other": "val"}}, {"id": 888, "stuff": {"info-spec": 200, "other": "val2"}}] | [
{
"id": 999,
"info-spec": 100
},
{
"id": 888,
"info-spec": 200
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/27562424/jq-nested-object-extract-top-level-id-and-lift-a-value-from-internal-object | jq: nested object, extract top-level id and lift a value from internal object | tripleee | tripleee | 27,562,901 | 42 | true |
so-28484534 | Read a stream of JSON objects and output a single object where each key's value is the sum of that key's values across all input objects. | jq -s '[.[] | to_entries] | add | group_by(.key) | map({key: .[0].key, value: map(.value) | add}) | from_entries' | { "a": 10, "b": 11 }
{ "a": 20, "b": 21 } | {
"a": 30,
"b": 32
}
| { "x": 5, "y": 10 }
{ "x": 15, "y": 20 }
{ "x": 0, "y": 5 } | {
"x": 20,
"y": 35
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/28484534/how-do-i-sum-the-values-in-an-array-of-maps-in-jq | How do I sum the values in an array of maps in jq? | Alan Burlison | Jeff Mercado | 28,485,485 | 46 | true |
so-29404575 | Convert a stream of JSON objects into a single JSON array containing all the objects. | jq -s '.' | {"a":1}
{"b":2} | [
{
"a": 1
},
{
"b": 2
}
]
| {"x":"foo"}
{"y":"bar"}
{"z":123} | [
{
"x": "foo"
},
{
"y": "bar"
},
{
"z": 123
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/29404575/how-to-convert-a-json-object-stream-into-an-array-with-jq | How to convert a JSON object stream into an array with jq | Qiang Li | Jeff Mercado | 29,404,613 | 46 | true |
so-29949184 | Filter a JSON object to keep only items with id "123" in the "requests" array if it exists and is non-empty, otherwise output nothing. | jq 'if (.requests | length) != 0 then .requests |= map(select(.id == "123")) else empty end' | {"requests":[{"id":"123"},{"id":"456"}]} | {
"requests": [
{
"id": "123"
}
]
}
| {"requests":[{"id":"789"}]} | {
"requests": []
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/29949184/json-jq-if-without-else | JSON JQ if without else | user1578872 | peak | 29,962,258 | 53 | true |
so-31034746 | Set the value of the key "local" inside the "shipping" object to false, preserving the rest of the JSON structure. | jq '.shipping.local = false' | {"shipping": {"local": true, "us": true, "us_rate": {"amount": "0.00", "currency": "USD", "symbol": "$"}}} | {
"shipping": {
"local": false,
"us": true,
"us_rate": {
"amount": "0.00",
"currency": "USD",
"symbol": "$"
}
}
}
| {"shipping": {"local": true, "international": false}, "other": "data"} | {
"shipping": {
"local": false,
"international": false
},
"other": "data"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/31034746/how-do-i-update-a-single-value-in-a-json-document-using-jq | How do I update a single value in a json document using jq? | STW | Jeff Mercado | 31,037,640 | 231 | true |
so-33247228 | Pretty-print the input JSON using jq's default formatting. | jq '.' | {"name": "octocat", "id": 1} | {
"name": "octocat",
"id": 1
}
| {"key": "value", "nested": {"a": 1}} | {
"key": "value",
"nested": {
"a": 1
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/33247228/how-to-use-jq-in-a-shell-pipeline | How to use `jq` in a shell pipeline? | mgalgs | chepner | 33,247,259 | 244 | true |
so-33895076 | Given a JSON array of objects containing 'timestamp', 'group', and 'uid' fields, output each object's 'group' and 'uid' values joined by a comma on separate lines. | jq -r '.[]|[.group,.uid]|join(",")' | [
{
"timestamp": 1448369447295,
"group": "employees",
"uid": "elgalu"
},
{
"timestamp": 1448369447296,
"group": "employees",
"uid": "mike"
},
{
"timestamp": 1448369786667,
"group": "services",
"uid": "pacts"
}
] | employees,elgalu
employees,mike
services,pacts
| [
{
"timestamp": 100,
"group": "admin",
"uid": "root"
},
{
"timestamp": 200,
"group": "users",
"uid": "guest"
}
] | admin,root
users,guest
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/33895076/exclude-column-from-jq-json-output | Exclude column from jq json output | Leo Gallucci | hek2mgl | 33,895,231 | 87 | true |
so-33947584 | Extract start_id and end_id from each JSON object and print them on the same line separated by a space, without surrounding double quotes. | jq -r '"\(.start_id) \(.end_id)"' | {"start_id":1,"end_id":50}
{"start_id":50,"end_id":99}
{"start_id":99,"end_id":12} | 1 50
50 99
99 12
| {"start_id":10,"end_id":20}
{"start_id":20,"end_id":30} | 10 20
20 30
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/33947584/concat-numbers-from-json-without-doublequotes-using-jq | Concat numbers from JSON without doublequotes using jq | Synesso | xjedam | 33,952,189 | 39 | true |
so-34226370 | Given a JSON object where keys are hostnames and values are objects containing an 'ip' field, output each hostname and its corresponding IP address as a comma-separated string on separate lines. | jq -r 'to_entries[] | "\(.key), \(.value.ip)"' | {
"host1": { "ip": "10.1.2.3" },
"host2": { "ip": "10.1.2.2" },
"host3": { "ip": "10.1.18.1" }
} | host1, 10.1.2.3
host2, 10.1.2.2
host3, 10.1.18.1
| {
"serverA": { "ip": "192.168.1.1" },
"serverB": { "ip": "192.168.1.2" }
} | serverA, 192.168.1.1
serverB, 192.168.1.2
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/34226370/jq-print-key-and-value-for-each-entry-in-an-object | jq: print key and value for each entry in an object | Jeff Tang | peak | 34,227,629 | 164 | true |
so-34340549 | Parse the JSON string contained in the "text" field of the "response" object and extract the "title" field from the parsed JSON. | jq '.response.text | fromjson | .title' | {
"requestType": "POST",
"response": {
"size": 78,
"text": "{\"recordID\":123, \"title\":\"Hello World\", \"content\":\"Lorem ipsum...\"}"
}
} | "Hello World"
| {
"requestType": "GET",
"response": {
"size": 50,
"text": "{\"id\":456, \"title\":\"Goodbye World\", \"data\":null}"
}
} | "Goodbye World"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/34340549/convert-string-to-json-in-jq | Convert string to json in jq | RJ-Adam | Jeff Mercado | 34,340,787 | 100 | true |
so-34543829 | Extract the 'def' value from the 'aux' array within each object of the top-level array. | jq -r '.[].aux[].def' | [{"id": 123, "name": "John", "aux": [{"abc": "random", "def": "I want this"}], "blah": 23.11}] | I want this
| [{"id": 456, "name": "Jane", "aux": [{"abc": "x", "def": "Target Value"}], "blah": 10.0}] | Target Value
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/34543829/jq-cannot-index-array-with-string | jq: Cannot index array with string | Xu Wang | hek2mgl | 34,544,406 | 115 | true |
so-35086391 | Given a JSON object where values are objects with a single key, output all the inner keys as a stream of strings. | jq '.[] | keys[]' | {
"keyword1": {
"identifier1": 16
},
"keyword2": {
"identifier2": 16
}
} | "identifier1"
"identifier2"
| {
"groupA": {
"nameA": 1
},
"groupB": {
"nameB": 2
}
} | "nameA"
"nameB"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/35086391/jq-how-to-iterate-through-keys-of-different-names | jq - How to iterate through keys of different names | Adam vonNieda | peak | 35,091,473 | 40 | true |
so-35154684 | Parse the JSON string contained in the field "c" and extract the value of its "id" field. | jq '.c | fromjson | .id' | {"a": 1, "b": 2, "c": "{\"id\":\"9ee\",\"parent\":\"abc\"}"} | "9ee"
| {"x": 10, "c": "{\"id\":\"xyz123\",\"type\":\"user\"}"} | "xyz123"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/35154684/how-to-parse-a-json-string-with-jq-or-other-alternatives | how to parse a JSON String with jq (or other alternatives)? | Colin Grogan | jwodder | 35,155,249 | 217 | true |
so-35677309 | Extract the "AssetId" value from each object in a JSON array and output them as raw strings. | jq -r '.[] | .AssetId' | [
{
"AssetId": 14462955,
"Name": "Cultural Item"
},
{
"AssetId": 114385498,
"Name": "Redspybot"
},
{
"AssetId": 29715011,
"Name": "American Cowboy"
},
{
"AssetId": 98253651,
"Name": "Mahem"
}
] | 14462955
114385498
29715011
98253651
| [
{
"AssetId": 100,
"Name": "Item A"
},
{
"AssetId": 200,
"Name": "Item B"
}
] | 100
200
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/35677309/output-specific-key-value-in-object-for-each-element-in-array-with-jq-for-json | Output specific key value in object for each element in array with jq for JSON | Zimbabwe Elephant | peak | 35,677,443 | 98 | true |
so-36227245 | Remove the keys "Country", "number", and "Language" from each object in a JSON array. | jq 'map(del(.Country, .number, .Language))' | [
{
"label": "US : USA : English",
"Country": "USA",
"region": "US",
"Language": "English",
"locale": "en",
"currency": "USD",
"number": "USD"
},
{
"label": "AU : Australia : English",
"Country": "Australia",
"region": "AU",
"Language": "English",
"locale": "en",
... | [
{
"label": "US : USA : English",
"region": "US",
"locale": "en",
"currency": "USD"
},
{
"label": "AU : Australia : English",
"region": "AU",
"locale": "en",
"currency": "AUD"
}
]
| [
{
"label": "CA : Canada : English",
"Country": "Canada",
"region": "CA",
"Language": "English",
"locale": "en",
"currency": "CAD",
"number": "CAD"
},
{
"label": "GB : UK : English",
"Country": "UK",
"region": "GB",
"Language": "English",
"locale": "en",
"curre... | [
{
"label": "CA : Canada : English",
"region": "CA",
"locale": "en",
"currency": "CAD"
},
{
"label": "GB : UK : English",
"region": "GB",
"locale": "en",
"currency": "GBP"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/36227245/deleting-multiple-keys-at-once-with-jq | Deleting multiple keys at once with jq | antun | user3899165 | 36,228,054 | 79 | true |
so-37344329 | Extract the value of the key "component-status" from a JSON object. | jq '."component-status"' | {
"status": "ok",
"hostname": "0b0b495a46db",
"component-status": [
{
"status-code": 200,
"component": "Service1",
"status": "OK"
},
{
"status-code": 200,
"component": "Service2",
"status": "OK"
}
]
} | [
{
"status-code": 200,
"component": "Service1",
"status": "OK"
},
{
"status-code": 200,
"component": "Service2",
"status": "OK"
}
]
| {
"status": "error",
"hostname": "test-host",
"component-status": [
{
"status-code": 500,
"component": "DB",
"status": "FAIL"
}
]
} | [
{
"status-code": 500,
"component": "DB",
"status": "FAIL"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37344329/jq-not-working-on-tag-name-with-dashes-and-numbers | jq not working on tag name with dashes and numbers | paul | fedorqui | 37,344,498 | 102 | true |
so-37563691 | Extract the md5 value from the object in the files array where the fileName is "FOO". | jq -r '.files[] | select(.fileName=="FOO") | .md5' | {"files": [{"fileName": "FOO", "md5": "blablabla"}, {"fileName": "BAR", "md5": "alaldlafj"}]} | blablabla
| {"files": [{"fileName": "TEST", "md5": "abc123"}, {"fileName": "FOO", "md5": "xyz789"}, {"fileName": "BAZ", "md5": "def456"}]} | xyz789
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37563691/jq-select-value-from-array | jq select value from array | Marvin Effing | Marvin Effing | 37,567,004 | 82 | true |
so-37577683 | Extract the value of the 'hostName' field from all top-level values in a JSON object, regardless of the top-level keys. | jq -r '.[].hostName' | {"key1": {"hostName": "server1", "state": "READY"}, "key2": {"hostName": "server2", "state": "STOPPED"}} | server1
server2
| {"abc-123": {"hostName": "node-alpha", "ip": "10.0.0.1"}, "xyz-789": {"hostName": "node-beta", "ip": "10.0.0.2"}} | node-alpha
node-beta
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37577683/how-to-use-jq-to-obtain-the-keys | How to use `jq` to obtain the keys | sudhishkr | Andreas Louv | 37,577,805 | 47 | true |
so-37710718 | Create a new JSON object containing a single field named 'channel' whose value is the concatenation of the input's 'profile_type', a dot, and the input's 'channel' value. | jq '{channel: (.profile_type + "." + .channel)}' | {"channel": "youtube", "profile_type": "video", "member_key": "hello"} | {
"channel": "video.youtube"
}
| {"channel": "twitch", "profile_type": "stream", "member_key": "world"} | {
"channel": "stream.twitch"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/37710718/concat-2-fields-in-json-using-jq | Concat 2 fields in JSON using jq | darthsidious | Anthony Battaglia | 37,710,802 | 177 | true |
so-38061346 | Read a stream of multiple JSON objects from stdin and combine them into a single JSON array. | jq -s '.' | {"name": "John", "email": "john@company.com"}
{"name": "Brad", "email": "brad@company.com"} | [
{
"name": "John",
"email": "john@company.com"
},
{
"name": "Brad",
"email": "brad@company.com"
}
]
| {"id": 1, "status": "active"}
{"id": 2, "status": "inactive"}
{"id": 3, "status": "pending"} | [
{
"id": 1,
"status": "active"
},
{
"id": 2,
"status": "inactive"
},
{
"id": 3,
"status": "pending"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38061346/jq-output-array-of-json-objects | jq: output array of json objects | Mauricio Trajano | chepner | 38,061,430 | 134 | true |
so-38121740 | Filter the 'theList' array to include only objects where the 'id' is either 2 or 4. | jq '.theList[] | select(.id == 2 or .id == 4)' | {"theList": [{"id": 1, "name": "Horst"}, {"id": 2, "name": "Fritz"}, {"id": 3, "name": "Walter"}, {"id": 4, "name": "Gerhart"}, {"id": 5, "name": "Harmut"}]} | {
"id": 2,
"name": "Fritz"
}
{
"id": 4,
"name": "Gerhart"
}
| {"theList": [{"id": 10, "name": "A"}, {"id": 2, "name": "B"}, {"id": 4, "name": "C"}, {"id": 5, "name": "D"}]} | {
"id": 2,
"name": "B"
}
{
"id": 4,
"name": "C"
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38121740/how-to-filter-array-of-objects-by-element-property-values-using-jq | How to filter array of objects by element property values using jq? | k0pernikus | André Senra | 38,122,029 | 120 | true |
so-38500363 | Select all objects from the input array where the key 'a' equals 'x', collect them into an array, and return the first element of that resulting array. | jq '[.[] | select(.a == "x")][0]' | [{"a": "x", "b": true}, {"a": "x", "b": false}, {"a": "XML", "b": false}] | {
"a": "x",
"b": true
}
| [{"a": "y", "b": true}, {"a": "x", "b": 123}, {"a": "x", "b": 456}] | {
"a": "x",
"b": 123
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38500363/get-the-first-or-nth-element-in-a-jq-json-parsing | get the first (or n'th) element in a jq json parsing | Demian Glait | hek2mgl | 38,500,610 | 128 | true |
so-38689645 | Select the parent object from a JSON structure where a nested field "details.name" equals "James Brown". | jq 'select(.details.name == "James Brown")' | {
"id": 1,
"details": {
"username": "jamesbrown",
"name": "James Brown"
}
} | {
"id": 1,
"details": {
"username": "jamesbrown",
"name": "James Brown"
}
}
| {
"id": 2,
"details": {
"username": "janedoe",
"name": "Jane Doe"
}
}
{
"id": 3,
"details": {
"username": "jamesbrown2",
"name": "James Brown"
}
} | {
"id": 3,
"details": {
"username": "jamesbrown2",
"name": "James Brown"
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/38689645/how-do-i-print-a-parent-value-of-an-object-when-i-am-already-deep-into-the-objec | How do I print a parent value of an object when I am already deep into the object's children? | x3nr0s | user3899165 | 38,693,695 | 75 | true |
so-39228500 | Extract all 'name' values from the array located at '.example."sub-example"' in the input JSON object. | jq '.example."sub-example" | .[] | .name' | {
"example": {
"sub-example": [
{
"name": "123-345",
"tag": 100
},
{
"name": "234-456",
"tag": 100
},
{
"name": "4a7-a07a5",
"tag": 100
}
]
}
} | "123-345"
"234-456"
"4a7-a07a5"
| {
"example": {
"sub-example": [
{
"name": "alpha",
"tag": 200
},
{
"name": "beta",
"tag": 200
}
]
}
} | "alpha"
"beta"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/39228500/extract-a-specific-field-from-json-output-using-jq | Extract a specific field from JSON output using jq | rmb | aaaaaa123456789 | 39,228,718 | 160 | true |
so-40396445 | Extract the key, status name, and assignee email address from each issue in the input JSON object's issues array, and output each result as a compact JSON object on a single line. | jq -c '.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress}' | {"issues": [{"key": "SEA-739", "fields": {"status": {"name": "Open"}, "assignee": null}}, {"key": "SEA-738", "fields": {"status": {"name": "Resolved"}, "assignee": {"emailAddress": "user2@mycompany.com"}}}]} | {"key":"SEA-739","status":"Open","assignee":null}
{"key":"SEA-738","status":"Resolved","assignee":"user2@mycompany.com"}
| {"issues": [{"key": "PROJ-101", "fields": {"status": {"name": "In Progress"}, "assignee": {"emailAddress": "dev@example.com"}}}, {"key": "PROJ-102", "fields": {"status": {"name": "Closed"}, "assignee": null}}]} | {"key":"PROJ-101","status":"In Progress","assignee":"dev@example.com"}
{"key":"PROJ-102","status":"Closed","assignee":null}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/40396445/get-outputs-from-jq-on-a-single-line | Get outputs from jq on a single line | Jitesh Sojitra | hmedia1 | 40,396,556 | 187 | true |
so-42051601 | From a JSON object with a 'data' field, extract the values of keys that case-insensitively match the pattern 'what a burger'. | jq '.data | to_entries | map(select(.key | match("what a burger";"i"))) | map(.value)' | {
"data": {
"what a burger": [1, 2, 3],
"wap": [66],
"the map": [11, 20],
"H. Incandenza": [1, 1],
"What a burger": ["a", "a", 3]
}
} | [
[
1,
2,
3
],
[
"a",
"a",
3
]
]
| {
"data": {
"WHAT A BURGER": [10, 20],
"other": [5],
"What a Burger": ["x", "y"]
}
} | [
[
10,
20
],
[
"x",
"y"
]
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42051601/pattern-matching-field-names-with-jq | Pattern matching field names with jq | manu | koalo | 42,051,804 | 45 | true |
so-42245288 | Append a new message object to the messages array within the data object of the input JSON. | jq '.data.messages += [{"date": "2010-01-07T19:55:99.999Z", "xml": "xml_samplesheet_2017_01_07_run_09.xml", "status": "OKKK", "message": "metadata loaded into iRODS successfullyyyyy"}]' | {"report": "1.0", "data": {"date": "2010-01-07", "messages": [{"date": "2010-01-07T19:58:42.949Z", "xml": "xml_samplesheet_2017_01_07_run_09.xml", "status": "OK", "message": "metadata loaded into iRODS successfully"}, {"date": "2010-01-07T20:22:46.949Z", "xml": "xml_samplesheet_2017_01_07_run_09.xml", "status": "NOK", ... | {
"report": "1.0",
"data": {
"date": "2010-01-07",
"messages": [
{
"date": "2010-01-07T19:58:42.949Z",
"xml": "xml_samplesheet_2017_01_07_run_09.xml",
"status": "OK",
"message": "metadata loaded into iRODS successfully"
},
{
"date": "2010-01-07T20:22... | {"report": "2.0", "data": {"date": "2011-01-07", "messages": [{"date": "2011-01-07T10:00:00.000Z", "xml": "test.xml", "status": "OK", "message": "test msg"}]}} | {
"report": "2.0",
"data": {
"date": "2011-01-07",
"messages": [
{
"date": "2011-01-07T10:00:00.000Z",
"xml": "test.xml",
"status": "OK",
"message": "test msg"
},
{
"date": "2010-01-07T19:55:99.999Z",
"xml": "xml_samplesheet_2017_01_07_run_09... | real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42245288/add-new-element-to-existing-json-array-with-jq | Add new element to existing JSON array with jq | Felipe | Inian | 42,248,841 | 133 | true |
so-42427725 | Convert an array of objects with 'name' and 'value' fields into a single object where each key is the 'name' value and the corresponding value is the original object. | jq 'map({(.name): .}) | add' | [
{"name": "A", "value": "1"},
{"name": "B", "value": "5"},
{"name": "E", "value": "8"}
] | {
"A": {
"name": "A",
"value": "1"
},
"B": {
"name": "B",
"value": "5"
},
"E": {
"name": "E",
"value": "8"
}
}
| [
{"name": "X", "value": "10"},
{"name": "Y", "value": "20"}
] | {
"X": {
"name": "X",
"value": "10"
},
"Y": {
"name": "Y",
"value": "20"
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42427725/using-jq-convert-array-of-objects-to-object-with-named-keys | Using jq, convert array of objects to object with named keys | Mike N | peak | 42,428,341 | 62 | true |
so-42746828 | Filter objects in a JSON array to keep only those where none of the strings in the "imageTags" array contain the text "latest". | jq '[.[] | select([.imageTags[] | contains("latest")] | any | not)]' | [
{
"imagePushedAt": 100,
"imageTags": ["v1", "stable"]
},
{
"imagePushedAt": 200,
"imageTags": ["v2", "latest"]
},
{
"imagePushedAt": 300,
"imageTags": ["v3"]
}
] | [
{
"imagePushedAt": 100,
"imageTags": [
"v1",
"stable"
]
},
{
"imagePushedAt": 300,
"imageTags": [
"v3"
]
}
]
| [
{
"imagePushedAt": 400,
"imageTags": ["release-candidate"]
},
{
"imagePushedAt": 500,
"imageTags": ["latest-build"]
},
{
"imagePushedAt": 600,
"imageTags": []
}
] | [
{
"imagePushedAt": 400,
"imageTags": [
"release-candidate"
]
},
{
"imagePushedAt": 600,
"imageTags": []
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/42746828/jq-how-to-query-for-array-values-that-dont-contain-text-foo | jq: how to query for array values that don't contain text "foo"? | Gavriel Fishel | J. Doe | 42,747,910 | 92 | true |
so-43221453 | Group an array of objects by their 'component' field and output separate objects for each component, where the key is the component name and the value is an array of the associated 'ip' addresses. | jq 'group_by(.component)[] | {(.[0].component): [.[] | .ip]}' | [
{"ip": "1.1.1.1", "component": "name1"},
{"ip": "1.1.1.2", "component": "name1"},
{"ip": "1.1.1.3", "component": "name2"},
{"ip": "1.1.1.4", "component": "name2"}
] | {
"name1": [
"1.1.1.1",
"1.1.1.2"
]
}
{
"name2": [
"1.1.1.3",
"1.1.1.4"
]
}
| [
{"ip": "2.2.2.1", "component": "web"},
{"ip": "2.2.2.2", "component": "db"},
{"ip": "2.2.2.3", "component": "web"}
] | {
"db": [
"2.2.2.2"
]
}
{
"web": [
"2.2.2.1",
"2.2.2.3"
]
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/43221453/jq-group-and-key-by-property | jq: group and key by property | replay | replay | 43,221,520 | 57 | true |
so-43291389 | Extract the absoluteNumber, airedEpisodeNumber, episodeName, and overview from each object in the data array, joining them with a pipe delimiter per line. | jq -r '.data[] | [.absoluteNumber, .airedEpisodeNumber, .episodeName, .overview] | join("|")' | {"data": [{"absoluteNumber": 51, "airedEpisodeNumber": 6, "episodeName": "We Will Rise", "overview": "Clarke and Roan must work together."}]} | 51|6|We Will Rise|Clarke and Roan must work together.
| {"data": [{"absoluteNumber": 10, "airedEpisodeNumber": 1, "episodeName": "Pilot", "overview": "The beginning."}, {"absoluteNumber": 11, "airedEpisodeNumber": 2, "episodeName": "Second", "overview": "Continuation."}]} | 10|1|Pilot|The beginning.
11|2|Second|Continuation.
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/43291389/using-jq-to-assign-multiple-output-variables | using jq to assign multiple output variables | user2328273 | Bertrand Martel | 43,293,515 | 43 | true |
so-43522133 | Rename the key "veg" to "fruit2" and "worker" to "job" in each object of a JSON array, removing the original keys. | jq '[.[] | .["fruit2"] = .veg | .["job"] = .worker | del(.veg, .worker)]' | [{"fruit":"strawberry","veg":"apple","worker":"gardener"}] | [
{
"fruit": "strawberry",
"fruit2": "apple",
"job": "gardener"
}
]
| [{"fruit":"banana","veg":"carrot","worker":"farmer"}] | [
{
"fruit": "banana",
"fruit2": "carrot",
"job": "farmer"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/43522133/using-jq-how-can-i-replace-the-name-of-a-key-with-something-else | Using jq how can I replace the name of a key with something else | user486670 | RomanPerekhrest | 43,522,716 | 53 | true |
so-44656515 | Extract the value of the 'name' field from a JSON object as raw text without surrounding quotes. | jq -r '.name' | {"name": "Google", "id": 1} | Google
| {"name": "Apple", "id": 2} | Apple
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/44656515/how-to-remove-double-quotes-in-jq-output-for-parsing-json-files-in-bash | How to remove double-quotes in jq output for parsing json files in bash? | Chris F | Charles Duffy | 44,656,583 | 800 | true |
so-45165303 | For each ticket in the 'tickets' array, output a CSV line where the 'tags' array is joined into a single comma-separated string field. | jq -r '.tickets[] | [.created_at, .id, .via.channel, (.tags | join(","))] | @csv' | {
"tickets": [
{
"created_at": "2016-02-02T10:00:00Z",
"id": 99999,
"via": { "channel": "web" },
"tags": ["tag1", "tag2", "tag3"]
}
]
} | "2016-02-02T10:00:00Z",99999,"web","tag1,tag2,tag3"
| {
"tickets": [
{
"created_at": "2023-01-01T00:00:00Z",
"id": 1,
"via": { "channel": "email" },
"tags": ["urgent", "bug"]
},
{
"created_at": "2023-01-02T00:00:00Z",
"id": 2,
"via": { "channel": "api" },
"tags": []
}
]
} | "2023-01-01T00:00:00Z",1,"email","urgent,bug"
"2023-01-02T00:00:00Z",2,"api",""
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/45165303/how-to-combine-an-array-into-a-single-string-value-when-using-csv-output-in-jq | How to combine an array into a single string value when using CSV output in jq? | Emre Sevinç | zwer | 45,165,687 | 45 | true |
so-45523425 | Extract the text field from all objects in the response array, ignoring non-object entries. | jq '.response[] | objects | .text' | {"response": [1000, {"id": 1, "text": "blabla"}, {"id": 2, "text": "hello world"}]} | "blabla"
"hello world"
| {"response": ["error", {"id": 5, "text": "first post"}, {"id": 6, "text": "second post"}, null]} | "first post"
"second post"
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/45523425/getting-all-the-values-of-an-array-with-jq | getting all the values of an array with jq | Miss Alena | peak | 45,524,015 | 80 | true |
so-46131727 | Extract the 'foo' and 'bar' values from the nested 'fmep' object and print them on the same line separated by a space. | jq -r '.fmep | "\(.foo) \(.bar)"' | {
"fmep": {
"foo": 112,
"bar": 234324,
"cat": 21343423
}
} | 112 234324
| {
"fmep": {
"foo": 5,
"bar": 10,
"cat": 15
}
} | 5 10
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/46131727/printing-multiple-values-on-the-same-line | Printing multiple values on the same line | Mickster | jq170727 | 46,131,963 | 58 | true |
so-47023795 | Remove the top-level 'pages' key and its value from the JSON object, keeping all other keys intact. | jq 'del(.pages)' | {
"pages": {
"elems": { "id": 1 }
},
"actions": {
"pages": { "id": 2 }
}
} | {
"actions": {
"pages": {
"id": 2
}
}
}
| {
"pages": {
"title": "Home"
},
"users": [
{ "name": "Alice" }
],
"settings": {
"theme": "dark"
}
} | {
"users": [
{
"name": "Alice"
}
],
"settings": {
"theme": "dark"
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/47023795/removing-a-key-from-parent-object-with-jq | Removing a key from parent object with jq | Nicholas | jq170727 | 47,024,050 | 44 | true |
so-48426052 | Given a JSON array of user objects, extract and print the 'username' field from each object on a new line. | jq -r '.[].username' | [
{
"username": "jdoe",
"name": "John Doe"
},
{
"username": "jadoe",
"name": "Jane Doe"
}
] | jdoe
jadoe
| [
{
"username": "alice",
"name": "Alice Smith"
},
{
"username": "bob",
"name": "Bob Jones"
}
] | alice
bob
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/48426052/how-to-extract-a-field-from-each-object-in-an-array-with-jq | How to extract a field from each object in an array with jq? | Chris F | John Kugelman | 48,426,543 | 84 | true |
so-49632521 | Add a new key-value pair '"operation": "delete"' to the 'fields' object located at .module.data.item_i77f664a2.fields in a JSON object. | jq '.module.data.item_i77f664a2.fields += {"operation": "delete"}' | {"success": true, "module": {"data": {"item_i77f664a2": {"id": "i77f664a2", "fields": {"cartItemId": 2012636322}, "type": "biz"}}}} | {
"success": true,
"module": {
"data": {
"item_i77f664a2": {
"id": "i77f664a2",
"fields": {
"cartItemId": 2012636322,
"operation": "delete"
},
"type": "biz"
}
}
}
}
| {"success": false, "module": {"data": {"item_i77f664a2": {"id": "other-id", "fields": {"qty": 5}, "type": "retail"}}}} | {
"success": false,
"module": {
"data": {
"item_i77f664a2": {
"id": "other-id",
"fields": {
"qty": 5,
"operation": "delete"
},
"type": "retail"
}
}
}
}
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/49632521/how-to-add-a-field-to-a-json-object-with-the-jq-command | How to add a field to a JSON object with the jq command? | Joe | peak | 49,632,947 | 46 | true |
so-50868203 | Filter a JSON array of objects to keep only those where the 'Address' field starts with a digit. | jq '[.[] | select(.Address | test("^[0-9]"))]' | [{"Address": "The Sq"}, {"Address": "1 Bridge Rd"}] | [
{
"Address": "1 Bridge Rd"
}
]
| [{"Address": "No Number St"}, {"Address": "99 Main Ave"}, {"Address": "Apt 5"}] | [
{
"Address": "99 Main Ave"
}
]
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/50868203/filter-by-regex-in-jq | Filter by Regex in JQ | user49 | peak | 50,868,294 | 48 | true |
so-52065570 | Read a stream of JSON objects from stdin, extract the 'duration' field from each, and output the sum of all durations as a single number. | jq -s '[.[].duration] | add' | {"duration": 1211789}
{"duration": 1211789}
{"duration": 373585} | 2797163
| {"duration": 100}
{"duration": 200}
{"duration": 300} | 600
| real-stackoverflow | 3 | test | stackoverflow-accepted-answer | CC-BY-SA-4.0 | https://stackoverflow.com/questions/52065570/how-do-i-sum-all-numbers-from-output-of-jq | How do I sum all numbers from output of jq | toy | Charles Duffy | 52,065,738 | 40 | true |
Jqweave Real 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
- 50 manually reviewed tasks from 50 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: 100 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-so-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 | 54.0% (27/50) | 10.0% (5/50) |
| Jqweave 1.5B | 62.0% (31/50) | 12.0% (6/50) |
| Jqweave 1.5B Real | 72.0% (36/50) | 24.0% (12/50) |
| Jqweave 1.5B Real v2 | 78.0% (39/50) | 38.0% (19/50) |
| Jqweave 3B Real | 80.0% (40/50) | 36.0% (18/50) |
| Jqweave 7B Real | 96.0% (48/50) | 66.0% (33/50) |
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
- 51