{"id":"so-23268506","request":"Recursively extract the values associated with the key \"updateDate\" from a nested JSON structure, ignoring non-object types and avoiding errors.","command":"jq '.. | objects | select(has(\"updateDate\")) | .updateDate'","input_text":"{\"a\": {\"updateDate\": \"2023-01-01\", \"b\": [{\"updateDate\": \"2023-02-02\"}, \"string\"]}, \"c\": 123}","expected_output":"\"2023-01-01\"\n\"2023-02-02\"\n","validation_input":"{\"x\": {\"y\": {\"updateDate\": \"now\"}}, \"z\": [1, {\"updateDate\": \"later\"}]}","validation_output":"\"now\"\n\"later\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/23268506/jq-select-objects-with-given-key-name","question_title":"jq - select objects with given key name","question_owner":"DisplayName","answer_owner":"user2259432","answer_id":24300334,"question_score":33,"reviewed":true} {"id":"so-23268506-p1","request":"Safely traverse a nested JSON structure to recursively collect all values linked to the key \"updateDate\", skipping non-object types to prevent errors.","command":"jq '.. | objects | select(has(\"updateDate\")) | .updateDate'","input_text":"{\"a\": {\"updateDate\": \"2023-01-01\", \"b\": [{\"updateDate\": \"2023-02-02\"}, \"string\"]}, \"c\": 123}","expected_output":"\"2023-01-01\"\n\"2023-02-02\"\n","validation_input":"{\"x\": {\"y\": {\"updateDate\": \"now\"}}, \"z\": [1, {\"updateDate\": \"later\"}]}","validation_output":"\"now\"\n\"later\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/23268506/jq-select-objects-with-given-key-name","question_title":"jq - select objects with given key name","question_owner":"DisplayName","answer_owner":"user2259432","answer_id":24300334,"question_score":33,"reviewed":true,"paraphrase_of":"so-23268506","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-25649960","request":"Filter a stream of JSON objects to include only those where the \"items\" array contains the string \"blue\".","command":"jq 'select(.items | index(\"blue\"))'","input_text":"{\"items\":[\"blue\",\"green\"]}\n{\"items\":[\"yellow\",\"green\"]}\n{\"items\":[\"blue\",\"pink\"]}","expected_output":"{\n \"items\": [\n \"blue\",\n \"green\"\n ]\n}\n{\n \"items\": [\n \"blue\",\n \"pink\"\n ]\n}\n","validation_input":"{\"items\":[\"red\",\"blue\"]}\n{\"items\":[\"green\"]}\n{\"items\":[\"blue\"]}","validation_output":"{\n \"items\": [\n \"red\",\n \"blue\"\n ]\n}\n{\n \"items\": [\n \"blue\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25649960/how-to-select-items-in-jq-based-on-value-in-array","question_title":"How to select items in JQ based on value in array","question_owner":"K2xL","answer_owner":"K2xL","answer_id":25650468,"question_score":32,"reviewed":true} {"id":"so-25649960-p1","request":"Process a stream of JSON objects and retain only those where the \"items\" array includes the string \"blue\".","command":"jq 'select(.items | index(\"blue\"))'","input_text":"{\"items\":[\"blue\",\"green\"]}\n{\"items\":[\"yellow\",\"green\"]}\n{\"items\":[\"blue\",\"pink\"]}","expected_output":"{\n \"items\": [\n \"blue\",\n \"green\"\n ]\n}\n{\n \"items\": [\n \"blue\",\n \"pink\"\n ]\n}\n","validation_input":"{\"items\":[\"red\",\"blue\"]}\n{\"items\":[\"green\"]}\n{\"items\":[\"blue\"]}","validation_output":"{\n \"items\": [\n \"red\",\n \"blue\"\n ]\n}\n{\n \"items\": [\n \"blue\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25649960/how-to-select-items-in-jq-based-on-value-in-array","question_title":"How to select items in JQ based on value in array","question_owner":"K2xL","answer_owner":"K2xL","answer_id":25650468,"question_score":32,"reviewed":true,"paraphrase_of":"so-25649960","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-27838154","request":"Filter an array of objects to keep only the 'name' key for each object.","command":"jq 'map({name})'","input_text":"[{\"name\": \"Alice\", \"group\": \"Admins\", \"created\": \"2014\"}, {\"name\": \"Bob\", \"group\": \"Users\", \"created\": \"2014\"}]","expected_output":"[\n {\n \"name\": \"Alice\"\n },\n {\n \"name\": \"Bob\"\n }\n]\n","validation_input":"[{\"name\": \"Charlie\", \"role\": \"Dev\", \"id\": 1}, {\"name\": \"Dave\", \"role\": \"Ops\", \"id\": 2}]","validation_output":"[\n {\n \"name\": \"Charlie\"\n },\n {\n \"name\": \"Dave\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/27838154/how-do-i-remove-all-keys-except-one-with-jq","question_title":"How do I remove all keys except one with jq?","question_owner":"Wilfred Hughes","answer_owner":"Girish","answer_id":27838881,"question_score":33,"reviewed":true} {"id":"so-27838154-p1","request":"Map an array of objects to a new array containing only the 'name' property from each original object.","command":"jq 'map({name})'","input_text":"[{\"name\": \"Alice\", \"group\": \"Admins\", \"created\": \"2014\"}, {\"name\": \"Bob\", \"group\": \"Users\", \"created\": \"2014\"}]","expected_output":"[\n {\n \"name\": \"Alice\"\n },\n {\n \"name\": \"Bob\"\n }\n]\n","validation_input":"[{\"name\": \"Charlie\", \"role\": \"Dev\", \"id\": 1}, {\"name\": \"Dave\", \"role\": \"Ops\", \"id\": 2}]","validation_output":"[\n {\n \"name\": \"Charlie\"\n },\n {\n \"name\": \"Dave\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/27838154/how-do-i-remove-all-keys-except-one-with-jq","question_title":"How do I remove all keys except one with jq?","question_owner":"Wilfred Hughes","answer_owner":"Girish","answer_id":27838881,"question_score":33,"reviewed":true,"paraphrase_of":"so-27838154","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-28593471","request":"Recursively unmarshal DynamoDB JSON output by converting typed wrappers (S, N, BOOL, M, L, SS, NS, BS) into their native JSON types.","command":"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) end elif type == \"array\" then map(decode) else . end; decode'","input_text":"{\n \"Count\": 1,\n \"Items\": [\n {\n \"Id\": {\n \"S\": \"app1\"\n },\n \"Parameters\": {\n \"M\": {\n \"nfs\": {\n \"M\": {\n \"IP\": {\n \"S\": \"172.16.0.178\"\n },\n \"activated\": {\n \"BOOL\": true\n }\n }\n },\n \"ws\": {\n \"M\": {\n \"number\": {\n \"N\": \"5\"\n },\n \"values\": {\n \"L\": [\n {\n \"S\": \"12253456346346\"\n },\n {\n \"S\": \"23452353463464\"\n }\n ]\n }\n }\n }\n }\n },\n \"Oldtypes\": {\n \"typeSS\": {\n \"SS\": [\n \"foo\",\n \"bar\"\n ]\n },\n \"typeNS\": {\n \"NS\": [\n \"0\",\n \"1\"\n ]\n }\n }\n }\n ],\n \"ScannedCount\": 1\n}","expected_output":"{\n \"Count\": 1,\n \"Items\": [\n {\n \"Id\": \"app1\",\n \"Parameters\": {\n \"nfs\": {\n \"IP\": \"172.16.0.178\",\n \"activated\": true\n },\n \"ws\": {\n \"number\": 5,\n \"values\": [\n \"12253456346346\",\n \"23452353463464\"\n ]\n }\n },\n \"Oldtypes\": {\n \"typeSS\": [\n \"foo\",\n \"bar\"\n ],\n \"typeNS\": [\n 0,\n 1\n ]\n }\n }\n ],\n \"ScannedCount\": 1\n}\n","validation_input":"{\n \"Count\": 2,\n \"Items\": [\n {\n \"Id\": {\n \"S\": \"item2\"\n },\n \"Data\": {\n \"M\": {\n \"active\": {\n \"BOOL\": false\n },\n \"score\": {\n \"N\": \"100\"\n }\n }\n }\n }\n ],\n \"ScannedCount\": 2\n}","validation_output":"{\n \"Count\": 2,\n \"Items\": [\n {\n \"Id\": \"item2\",\n \"Data\": {\n \"active\": false,\n \"score\": 100\n }\n }\n ],\n \"ScannedCount\": 2\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28593471/how-to-simplify-aws-dynamodb-query-json-output-from-the-command-line","question_title":"How to simplify aws DynamoDB query JSON output from the command line?","question_owner":"herve","answer_owner":"Jeff Mercado","answer_id":28641626,"question_score":32,"reviewed":true} {"id":"so-28593471-p1","request":"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.","command":"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) end elif type == \"array\" then map(decode) else . end; decode'","input_text":"{\n \"Count\": 1,\n \"Items\": [\n {\n \"Id\": {\n \"S\": \"app1\"\n },\n \"Parameters\": {\n \"M\": {\n \"nfs\": {\n \"M\": {\n \"IP\": {\n \"S\": \"172.16.0.178\"\n },\n \"activated\": {\n \"BOOL\": true\n }\n }\n },\n \"ws\": {\n \"M\": {\n \"number\": {\n \"N\": \"5\"\n },\n \"values\": {\n \"L\": [\n {\n \"S\": \"12253456346346\"\n },\n {\n \"S\": \"23452353463464\"\n }\n ]\n }\n }\n }\n }\n },\n \"Oldtypes\": {\n \"typeSS\": {\n \"SS\": [\n \"foo\",\n \"bar\"\n ]\n },\n \"typeNS\": {\n \"NS\": [\n \"0\",\n \"1\"\n ]\n }\n }\n }\n ],\n \"ScannedCount\": 1\n}","expected_output":"{\n \"Count\": 1,\n \"Items\": [\n {\n \"Id\": \"app1\",\n \"Parameters\": {\n \"nfs\": {\n \"IP\": \"172.16.0.178\",\n \"activated\": true\n },\n \"ws\": {\n \"number\": 5,\n \"values\": [\n \"12253456346346\",\n \"23452353463464\"\n ]\n }\n },\n \"Oldtypes\": {\n \"typeSS\": [\n \"foo\",\n \"bar\"\n ],\n \"typeNS\": [\n 0,\n 1\n ]\n }\n }\n ],\n \"ScannedCount\": 1\n}\n","validation_input":"{\n \"Count\": 2,\n \"Items\": [\n {\n \"Id\": {\n \"S\": \"item2\"\n },\n \"Data\": {\n \"M\": {\n \"active\": {\n \"BOOL\": false\n },\n \"score\": {\n \"N\": \"100\"\n }\n }\n }\n }\n ],\n \"ScannedCount\": 2\n}","validation_output":"{\n \"Count\": 2,\n \"Items\": [\n {\n \"Id\": \"item2\",\n \"Data\": {\n \"active\": false,\n \"score\": 100\n }\n }\n ],\n \"ScannedCount\": 2\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28593471/how-to-simplify-aws-dynamodb-query-json-output-from-the-command-line","question_title":"How to simplify aws DynamoDB query JSON output from the command line?","question_owner":"herve","answer_owner":"Jeff Mercado","answer_id":28641626,"question_score":32,"reviewed":true,"paraphrase_of":"so-28593471","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-28615174","request":"Filter a JSON object to keep only entries where the nested 'Job' field is equal to 'Clown'.","command":"jq 'with_entries(select(.value.Job == \"Clown\"))'","input_text":"{\"Joe\": {\"Job\": \"Clown\", \"Age\": 22}, \"Sally\": {\"Job\": \"Programmer\", \"Age\": 32}, \"Anne\": {\"Job\": \"Clown\", \"Age\": 29}}","expected_output":"{\n \"Joe\": {\n \"Job\": \"Clown\",\n \"Age\": 22\n },\n \"Anne\": {\n \"Job\": \"Clown\",\n \"Age\": 29\n }\n}\n","validation_input":"{\"Bob\": {\"Job\": \"Clown\", \"Age\": 40}, \"Alice\": {\"Job\": \"Doctor\", \"Age\": 30}}","validation_output":"{\n \"Bob\": {\n \"Job\": \"Clown\",\n \"Age\": 40\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28615174/jq-filter-on-sub-object-value","question_title":"jq Filter on sub object value","question_owner":"Christopher Helck","answer_owner":"Hans Z.","answer_id":28617380,"question_score":18,"reviewed":true} {"id":"so-28615174-p1","request":"Filter a JSON object to retain only the entries where the nested 'Job' field matches the value 'Clown'.","command":"jq 'with_entries(select(.value.Job == \"Clown\"))'","input_text":"{\"Joe\": {\"Job\": \"Clown\", \"Age\": 22}, \"Sally\": {\"Job\": \"Programmer\", \"Age\": 32}, \"Anne\": {\"Job\": \"Clown\", \"Age\": 29}}","expected_output":"{\n \"Joe\": {\n \"Job\": \"Clown\",\n \"Age\": 22\n },\n \"Anne\": {\n \"Job\": \"Clown\",\n \"Age\": 29\n }\n}\n","validation_input":"{\"Bob\": {\"Job\": \"Clown\", \"Age\": 40}, \"Alice\": {\"Job\": \"Doctor\", \"Age\": 30}}","validation_output":"{\n \"Bob\": {\n \"Job\": \"Clown\",\n \"Age\": 40\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28615174/jq-filter-on-sub-object-value","question_title":"jq Filter on sub object value","question_owner":"Christopher Helck","answer_owner":"Hans Z.","answer_id":28617380,"question_score":18,"reviewed":true,"paraphrase_of":"so-28615174","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-29389010","request":"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.","command":"jq '[ .devices | to_entries[] | select(.key | startswith(\"dimmer\")) | {key: .key, value: .value.state} ] | from_entries'","input_text":"{\n \"devices\": {\n \"dimmer1\": {\n \"protocol\": [\"kaku_dimmer\"],\n \"state\": \"off\",\n \"dimlevel\": 1\n },\n \"dimmer2\": {\n \"protocol\": [\"kaku_dimmer\"],\n \"state\": \"on\",\n \"dimlevel\": 5\n },\n \"switch1\": {\n \"protocol\": [\"kaku_switch\"],\n \"state\": \"off\"\n }\n }\n}","expected_output":"{\n \"dimmer1\": \"off\",\n \"dimmer2\": \"on\"\n}\n","validation_input":"{\n \"devices\": {\n \"dimmerA\": {\n \"protocol\": [\"proto_a\"],\n \"state\": \"on\",\n \"dimlevel\": 10\n },\n \"lightB\": {\n \"protocol\": [\"proto_b\"],\n \"state\": \"off\"\n },\n \"dimmerC\": {\n \"protocol\": [\"proto_c\"],\n \"state\": \"off\",\n \"dimlevel\": 0\n }\n }\n}","validation_output":"{\n \"dimmerA\": \"on\",\n \"dimmerC\": \"off\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29389010/jq-parsing-get-value","question_title":"jq parsing get value","question_owner":"user3467696","answer_owner":"Wintermute","answer_id":29389469,"question_score":32,"reviewed":true} {"id":"so-29389010-p1","request":"From the 'devices' object, filter keys starting with 'dimmer' and construct a new object mapping these keys to their corresponding 'state' values.","command":"jq '[ .devices | to_entries[] | select(.key | startswith(\"dimmer\")) | {key: .key, value: .value.state} ] | from_entries'","input_text":"{\n \"devices\": {\n \"dimmer1\": {\n \"protocol\": [\"kaku_dimmer\"],\n \"state\": \"off\",\n \"dimlevel\": 1\n },\n \"dimmer2\": {\n \"protocol\": [\"kaku_dimmer\"],\n \"state\": \"on\",\n \"dimlevel\": 5\n },\n \"switch1\": {\n \"protocol\": [\"kaku_switch\"],\n \"state\": \"off\"\n }\n }\n}","expected_output":"{\n \"dimmer1\": \"off\",\n \"dimmer2\": \"on\"\n}\n","validation_input":"{\n \"devices\": {\n \"dimmerA\": {\n \"protocol\": [\"proto_a\"],\n \"state\": \"on\",\n \"dimlevel\": 10\n },\n \"lightB\": {\n \"protocol\": [\"proto_b\"],\n \"state\": \"off\"\n },\n \"dimmerC\": {\n \"protocol\": [\"proto_c\"],\n \"state\": \"off\",\n \"dimlevel\": 0\n }\n }\n}","validation_output":"{\n \"dimmerA\": \"on\",\n \"dimmerC\": \"off\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29389010/jq-parsing-get-value","question_title":"jq parsing get value","question_owner":"user3467696","answer_owner":"Wintermute","answer_id":29389469,"question_score":32,"reviewed":true,"paraphrase_of":"so-29389010","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-29772676","request":"Update the 'format' field to 'csv' for the object in the array where the 'id' is 'baz'.","command":"jq '(.. | objects | select(.id == \"baz\") | .format) |= \"csv\"'","input_text":"[\n {\n \"format\": \"geojson\",\n \"id\": \"foo\"\n },\n {\n \"format\": \"geojson\",\n \"id\": \"bar\"\n },\n {\n \"format\": \"zip\",\n \"id\": \"baz\"\n }\n]","expected_output":"[\n {\n \"format\": \"geojson\",\n \"id\": \"foo\"\n },\n {\n \"format\": \"geojson\",\n \"id\": \"bar\"\n },\n {\n \"format\": \"csv\",\n \"id\": \"baz\"\n }\n]\n","validation_input":"[\n {\n \"format\": \"xml\",\n \"id\": \"alpha\"\n },\n {\n \"format\": \"json\",\n \"id\": \"beta\"\n },\n {\n \"format\": \"yaml\",\n \"id\": \"baz\"\n },\n {\n \"format\": \"txt\",\n \"id\": \"gamma\"\n }\n]","validation_output":"[\n {\n \"format\": \"xml\",\n \"id\": \"alpha\"\n },\n {\n \"format\": \"json\",\n \"id\": \"beta\"\n },\n {\n \"format\": \"csv\",\n \"id\": \"baz\"\n },\n {\n \"format\": \"txt\",\n \"id\": \"gamma\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29772676/update-one-value-in-array-of-dicts-using-jq","question_title":"Update one value in array of dicts, using jq","question_owner":"Steve Bennett","answer_owner":"Hans Z.","answer_id":29773197,"question_score":32,"reviewed":true} {"id":"so-29772676-p1","request":"Locate the object with 'id' equal to 'baz' within an array and update its 'format' field to 'csv'.","command":"jq '(.. | objects | select(.id == \"baz\") | .format) |= \"csv\"'","input_text":"[\n {\n \"format\": \"geojson\",\n \"id\": \"foo\"\n },\n {\n \"format\": \"geojson\",\n \"id\": \"bar\"\n },\n {\n \"format\": \"zip\",\n \"id\": \"baz\"\n }\n]","expected_output":"[\n {\n \"format\": \"geojson\",\n \"id\": \"foo\"\n },\n {\n \"format\": \"geojson\",\n \"id\": \"bar\"\n },\n {\n \"format\": \"csv\",\n \"id\": \"baz\"\n }\n]\n","validation_input":"[\n {\n \"format\": \"xml\",\n \"id\": \"alpha\"\n },\n {\n \"format\": \"json\",\n \"id\": \"beta\"\n },\n {\n \"format\": \"yaml\",\n \"id\": \"baz\"\n },\n {\n \"format\": \"txt\",\n \"id\": \"gamma\"\n }\n]","validation_output":"[\n {\n \"format\": \"xml\",\n \"id\": \"alpha\"\n },\n {\n \"format\": \"json\",\n \"id\": \"beta\"\n },\n {\n \"format\": \"csv\",\n \"id\": \"baz\"\n },\n {\n \"format\": \"txt\",\n \"id\": \"gamma\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29772676/update-one-value-in-array-of-dicts-using-jq","question_title":"Update one value in array of dicts, using jq","question_owner":"Steve Bennett","answer_owner":"Hans Z.","answer_id":29773197,"question_score":32,"reviewed":true,"paraphrase_of":"so-29772676","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-29982897","request":"For each object in the 'snapshots' array, output a single line containing the 'end_time_in_millis' and 'snapshot' values separated by a space.","command":"jq -r '.snapshots[] | \"\\(.end_time_in_millis) \\(.snapshot)\"'","input_text":"{\"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, \"duration_in_millis\": 243726}, {\"shards\": {\"successful\": 1, \"failed\": 0, \"total\": 1}, \"failures\": [], \"snapshot\": \"snapshot_2\", \"indices\": [\"myindex1\"], \"state\": \"SUCCESS\", \"start_time\": \"2015-04-22T05:36:02.333Z\", \"start_time_in_millis\": 1429680962333, \"end_time\": \"2015-04-22T05:39:29.896Z\", \"end_time_in_millis\": 1429681169896, \"duration_in_millis\": 207563}]}","expected_output":"1429609790767 snapshot_1\n1429681169896 snapshot_2\n","validation_input":"{\"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_millis\": 60000}]}","validation_output":"1000000060000 snap_A\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29982897/using-jq-to-extract-specific-property-values-and-output-on-a-single-line","question_title":"Using jq to extract specific property values and output on a single line","question_owner":"mark","answer_owner":"Jeff Mercado","answer_id":29982986,"question_score":19,"reviewed":true} {"id":"so-29982897-p1","request":"Iterate through the 'snapshots' array and print each 'end_time_in_millis' and 'snapshot' value on a single line, separated by a space.","command":"jq -r '.snapshots[] | \"\\(.end_time_in_millis) \\(.snapshot)\"'","input_text":"{\"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, \"duration_in_millis\": 243726}, {\"shards\": {\"successful\": 1, \"failed\": 0, \"total\": 1}, \"failures\": [], \"snapshot\": \"snapshot_2\", \"indices\": [\"myindex1\"], \"state\": \"SUCCESS\", \"start_time\": \"2015-04-22T05:36:02.333Z\", \"start_time_in_millis\": 1429680962333, \"end_time\": \"2015-04-22T05:39:29.896Z\", \"end_time_in_millis\": 1429681169896, \"duration_in_millis\": 207563}]}","expected_output":"1429609790767 snapshot_1\n1429681169896 snapshot_2\n","validation_input":"{\"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_millis\": 60000}]}","validation_output":"1000000060000 snap_A\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29982897/using-jq-to-extract-specific-property-values-and-output-on-a-single-line","question_title":"Using jq to extract specific property values and output on a single line","question_owner":"mark","answer_owner":"Jeff Mercado","answer_id":29982986,"question_score":19,"reviewed":true,"paraphrase_of":"so-29982897","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-30015555","request":"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'.","command":"jq -r 'map({message: .commit.message, name: .commit.committer.name}) | (.[0] | to_entries | map(.key)), (.[] | [.[]]) | @csv'","input_text":"[{\"commit\": {\"message\": \"Fix README\", \"committer\": {\"name\": \"Nicolas Williams\"}}}, {\"commit\": {\"message\": \"Update docs\", \"committer\": {\"name\": \"John Doe\"}}}]","expected_output":"\"message\",\"name\"\n\"Fix README\",\"Nicolas Williams\"\n\"Update docs\",\"John Doe\"\n","validation_input":"[{\"commit\": {\"message\": \"Initial commit\", \"committer\": {\"name\": \"Alice\"}}}, {\"commit\": {\"message\": \"Bug fix\", \"committer\": {\"name\": \"Bob\"}}}]","validation_output":"\"message\",\"name\"\n\"Initial commit\",\"Alice\"\n\"Bug fix\",\"Bob\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30015555/how-to-add-a-header-to-csv-export-in-jq","question_title":"How to add a header to CSV export in jq?","question_owner":"Anton Tarasenko","answer_owner":"user3899165","answer_id":30032247,"question_score":35,"reviewed":true} {"id":"so-30015555-p1","request":"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.","command":"jq -r 'map({message: .commit.message, name: .commit.committer.name}) | (.[0] | to_entries | map(.key)), (.[] | [.[]]) | @csv'","input_text":"[{\"commit\": {\"message\": \"Fix README\", \"committer\": {\"name\": \"Nicolas Williams\"}}}, {\"commit\": {\"message\": \"Update docs\", \"committer\": {\"name\": \"John Doe\"}}}]","expected_output":"\"message\",\"name\"\n\"Fix README\",\"Nicolas Williams\"\n\"Update docs\",\"John Doe\"\n","validation_input":"[{\"commit\": {\"message\": \"Initial commit\", \"committer\": {\"name\": \"Alice\"}}}, {\"commit\": {\"message\": \"Bug fix\", \"committer\": {\"name\": \"Bob\"}}}]","validation_output":"\"message\",\"name\"\n\"Initial commit\",\"Alice\"\n\"Bug fix\",\"Bob\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30015555/how-to-add-a-header-to-csv-export-in-jq","question_title":"How to add a header to CSV export in jq?","question_owner":"Anton Tarasenko","answer_owner":"user3899165","answer_id":30032247,"question_score":35,"reviewed":true,"paraphrase_of":"so-30015555","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-30601278","request":"Extract OwnerId, InstanceId, ImageId, PrivateIpAddress, and Platform from nested Reservations and Instances arrays into a flat object for each instance.","command":"jq '.Reservations[] | .OwnerId as $OwnerId | (.Instances[] | { \"OwnerId\": $OwnerId, InstanceId, ImageId, PrivateIpAddress, Platform})'","input_text":"{\"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\": \"windows\", \"PrivateIpAddress\": \"10.0.0.0\", \"ProductCodes\": [{\"ProductCodeId\": \"0000000000000000000000000\", \"ProductCodeType\": \"marketplace\"}], \"VpcId\": \"vpc-2222222\", \"StateTransitionReason\": null, \"InstanceId\": \"i-v33333333\", \"ImageId\": \"ami-44444444\", \"PrivateDnsName\": \"ip-10-0-0-0.aws.foobarcloud.com\", \"KeyName\": \"bar-servicemesh\", \"SecurityGroups\": [{\"GroupName\": \"bar-wildcard-dns-intranet-InstanceSecurityGroup-VN0DFQ13QCDY\", \"GroupId\": \"sg-55555555\"}], \"ClientToken\": \"11111111-2222-3333-4444-555555555555_subnet-66666666_1\", \"SubnetId\": \"subnet-66666666\", \"InstanceType\": \"t2.medium\", \"NetworkInterfaces\": [{\"Status\": \"in-use\", \"MacAddress\": \"00:00:00:00:00:77\", \"SourceDestCheck\": true, \"VpcId\": \"vpc-66666666\", \"Description\": null, \"NetworkInterfaceId\": \"eni-11111111\"}]}]}]}","expected_output":"{\n \"OwnerId\": \"000000000000\",\n \"InstanceId\": \"i-v33333333\",\n \"ImageId\": \"ami-44444444\",\n \"PrivateIpAddress\": \"10.0.0.0\",\n \"Platform\": \"windows\"\n}\n","validation_input":"{\"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:03:03.000Z\", \"Platform\": \"linux\", \"PrivateIpAddress\": \"192.168.1.1\", \"ProductCodes\": [], \"VpcId\": \"vpc-3333333\", \"StateTransitionReason\": null, \"InstanceId\": \"i-a11111111\", \"ImageId\": \"ami-55555555\", \"PrivateDnsName\": \"ip-192-168-1-1.ec2.internal\", \"KeyName\": \"my-key\", \"SecurityGroups\": [], \"ClientToken\": \"token\", \"SubnetId\": \"subnet-77777777\", \"InstanceType\": \"m3.large\", \"NetworkInterfaces\": []}]}]}","validation_output":"{\n \"OwnerId\": \"111111111111\",\n \"InstanceId\": \"i-a11111111\",\n \"ImageId\": \"ami-55555555\",\n \"PrivateIpAddress\": \"192.168.1.1\",\n \"Platform\": \"linux\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30601278/how-to-extract-keys-from-multiple-nested-arrays-using-jq","question_title":"How to extract keys from multiple, nested arrays using jq","question_owner":"Paul Ericson","answer_owner":"Hans Z.","answer_id":30602908,"question_score":19,"reviewed":true} {"id":"so-30601278-p1","request":"Flatten nested Reservations and Instances arrays into individual objects, extracting OwnerId, InstanceId, ImageId, PrivateIpAddress, and Platform for each instance.","command":"jq '.Reservations[] | .OwnerId as $OwnerId | (.Instances[] | { \"OwnerId\": $OwnerId, InstanceId, ImageId, PrivateIpAddress, Platform})'","input_text":"{\"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\": \"windows\", \"PrivateIpAddress\": \"10.0.0.0\", \"ProductCodes\": [{\"ProductCodeId\": \"0000000000000000000000000\", \"ProductCodeType\": \"marketplace\"}], \"VpcId\": \"vpc-2222222\", \"StateTransitionReason\": null, \"InstanceId\": \"i-v33333333\", \"ImageId\": \"ami-44444444\", \"PrivateDnsName\": \"ip-10-0-0-0.aws.foobarcloud.com\", \"KeyName\": \"bar-servicemesh\", \"SecurityGroups\": [{\"GroupName\": \"bar-wildcard-dns-intranet-InstanceSecurityGroup-VN0DFQ13QCDY\", \"GroupId\": \"sg-55555555\"}], \"ClientToken\": \"11111111-2222-3333-4444-555555555555_subnet-66666666_1\", \"SubnetId\": \"subnet-66666666\", \"InstanceType\": \"t2.medium\", \"NetworkInterfaces\": [{\"Status\": \"in-use\", \"MacAddress\": \"00:00:00:00:00:77\", \"SourceDestCheck\": true, \"VpcId\": \"vpc-66666666\", \"Description\": null, \"NetworkInterfaceId\": \"eni-11111111\"}]}]}]}","expected_output":"{\n \"OwnerId\": \"000000000000\",\n \"InstanceId\": \"i-v33333333\",\n \"ImageId\": \"ami-44444444\",\n \"PrivateIpAddress\": \"10.0.0.0\",\n \"Platform\": \"windows\"\n}\n","validation_input":"{\"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:03:03.000Z\", \"Platform\": \"linux\", \"PrivateIpAddress\": \"192.168.1.1\", \"ProductCodes\": [], \"VpcId\": \"vpc-3333333\", \"StateTransitionReason\": null, \"InstanceId\": \"i-a11111111\", \"ImageId\": \"ami-55555555\", \"PrivateDnsName\": \"ip-192-168-1-1.ec2.internal\", \"KeyName\": \"my-key\", \"SecurityGroups\": [], \"ClientToken\": \"token\", \"SubnetId\": \"subnet-77777777\", \"InstanceType\": \"m3.large\", \"NetworkInterfaces\": []}]}]}","validation_output":"{\n \"OwnerId\": \"111111111111\",\n \"InstanceId\": \"i-a11111111\",\n \"ImageId\": \"ami-55555555\",\n \"PrivateIpAddress\": \"192.168.1.1\",\n \"Platform\": \"linux\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30601278/how-to-extract-keys-from-multiple-nested-arrays-using-jq","question_title":"How to extract keys from multiple, nested arrays using jq","question_owner":"Paul Ericson","answer_owner":"Hans Z.","answer_id":30602908,"question_score":19,"reviewed":true,"paraphrase_of":"so-30601278","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-33627427","request":"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.","command":"jq '.p | map_values(keys)'","input_text":"{\"p\": {\"d\": {\"a\": {\"r\": \"foo\"}, \"b\": {\"r\": \"bar\"}}, \"c\": {\"e\": {\"r\": \"baz\"}}}}","expected_output":"{\n \"d\": [\n \"a\",\n \"b\"\n ],\n \"c\": [\n \"e\"\n ]\n}\n","validation_input":"{\"p\": {\"group1\": {\"item1\": {}, \"item2\": {}}, \"group2\": {\"item3\": {}}}}","validation_output":"{\n \"group1\": [\n \"item1\",\n \"item2\"\n ],\n \"group2\": [\n \"item3\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33627427/jq-getting-two-levels-of-keys","question_title":"jq: Getting two levels of keys","question_owner":"Henrik supports the community","answer_owner":"user3899165","answer_id":33630944,"question_score":33,"reviewed":true} {"id":"so-33627427-p1","request":"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.","command":"jq '.p | map_values(keys)'","input_text":"{\"p\": {\"d\": {\"a\": {\"r\": \"foo\"}, \"b\": {\"r\": \"bar\"}}, \"c\": {\"e\": {\"r\": \"baz\"}}}}","expected_output":"{\n \"d\": [\n \"a\",\n \"b\"\n ],\n \"c\": [\n \"e\"\n ]\n}\n","validation_input":"{\"p\": {\"group1\": {\"item1\": {}, \"item2\": {}}, \"group2\": {\"item3\": {}}}}","validation_output":"{\n \"group1\": [\n \"item1\",\n \"item2\"\n ],\n \"group2\": [\n \"item3\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33627427/jq-getting-two-levels-of-keys","question_title":"jq: Getting two levels of keys","question_owner":"Henrik supports the community","answer_owner":"user3899165","answer_id":33630944,"question_score":33,"reviewed":true,"paraphrase_of":"so-33627427","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-35540294","request":"Sort the input JSON array of objects first by 'prop1' in descending order, and then by 'prop2' in ascending order.","command":"jq 'sort_by(-.prop1, .prop2)'","input_text":"[{\"name\": \"Object 1\", \"prop1\": 5, \"prop2\": 2}, {\"name\": \"Object 2\", \"prop1\": 6, \"prop2\": 4}, {\"name\": \"Object 3\", \"prop1\": 5, \"prop2\": 3}]","expected_output":"[\n {\n \"name\": \"Object 2\",\n \"prop1\": 6,\n \"prop2\": 4\n },\n {\n \"name\": \"Object 1\",\n \"prop1\": 5,\n \"prop2\": 2\n },\n {\n \"name\": \"Object 3\",\n \"prop1\": 5,\n \"prop2\": 3\n }\n]\n","validation_input":"[{\"name\": \"A\", \"prop1\": 10, \"prop2\": 1}, {\"name\": \"B\", \"prop1\": 10, \"prop2\": 2}, {\"name\": \"C\", \"prop1\": 5, \"prop2\": 1}]","validation_output":"[\n {\n \"name\": \"A\",\n \"prop1\": 10,\n \"prop2\": 1\n },\n {\n \"name\": \"B\",\n \"prop1\": 10,\n \"prop2\": 2\n },\n {\n \"name\": \"C\",\n \"prop1\": 5,\n \"prop2\": 1\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35540294/sort-descending-by-multiple-keys-in-jq","question_title":"Sort descending by multiple keys in jq","question_owner":"Roland Weisleder","answer_owner":"user3899165","answer_id":35541425,"question_score":36,"reviewed":true} {"id":"so-35540294-p1","request":"Sort an array of JSON objects primarily by 'prop1' in descending order, using 'prop2' in ascending order as the secondary sort criterion.","command":"jq 'sort_by(-.prop1, .prop2)'","input_text":"[{\"name\": \"Object 1\", \"prop1\": 5, \"prop2\": 2}, {\"name\": \"Object 2\", \"prop1\": 6, \"prop2\": 4}, {\"name\": \"Object 3\", \"prop1\": 5, \"prop2\": 3}]","expected_output":"[\n {\n \"name\": \"Object 2\",\n \"prop1\": 6,\n \"prop2\": 4\n },\n {\n \"name\": \"Object 1\",\n \"prop1\": 5,\n \"prop2\": 2\n },\n {\n \"name\": \"Object 3\",\n \"prop1\": 5,\n \"prop2\": 3\n }\n]\n","validation_input":"[{\"name\": \"A\", \"prop1\": 10, \"prop2\": 1}, {\"name\": \"B\", \"prop1\": 10, \"prop2\": 2}, {\"name\": \"C\", \"prop1\": 5, \"prop2\": 1}]","validation_output":"[\n {\n \"name\": \"A\",\n \"prop1\": 10,\n \"prop2\": 1\n },\n {\n \"name\": \"B\",\n \"prop1\": 10,\n \"prop2\": 2\n },\n {\n \"name\": \"C\",\n \"prop1\": 5,\n \"prop2\": 1\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35540294/sort-descending-by-multiple-keys-in-jq","question_title":"Sort descending by multiple keys in jq","question_owner":"Roland Weisleder","answer_owner":"user3899165","answer_id":35541425,"question_score":36,"reviewed":true,"paraphrase_of":"so-35540294","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-37540717","request":"Flatten a nested JSON object into a single-level object where keys are dot-separated paths to leaf values.","command":"jq '[paths(scalars) as $path | {\"key\": $path | join(\".\"), \"value\": getpath($path)}] | from_entries'","input_text":"{\"a\":{\"b\":1}}","expected_output":"{\n \"a.b\": 1\n}\n","validation_input":"{\"x\":{\"y\":{\"z\":2},\"w\":3}}","validation_output":"{\n \"x.y.z\": 2,\n \"x.w\": 3\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37540717/flatten-nested-json-using-jq","question_title":"Flatten nested JSON using jq","question_owner":"assafmo","answer_owner":"user3899165","answer_id":37555908,"question_score":20,"reviewed":true} {"id":"so-37540717-p1","request":"Convert a nested JSON structure into a flat object, using dot notation for keys that represent the path to each leaf value.","command":"jq '[paths(scalars) as $path | {\"key\": $path | join(\".\"), \"value\": getpath($path)}] | from_entries'","input_text":"{\"a\":{\"b\":1}}","expected_output":"{\n \"a.b\": 1\n}\n","validation_input":"{\"x\":{\"y\":{\"z\":2},\"w\":3}}","validation_output":"{\n \"x.y.z\": 2,\n \"x.w\": 3\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37540717/flatten-nested-json-using-jq","question_title":"Flatten nested JSON using jq","question_owner":"assafmo","answer_owner":"user3899165","answer_id":37555908,"question_score":20,"reviewed":true,"paraphrase_of":"so-37540717","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-38186594","request":"Select objects from an array where the test field is strictly boolean false.","command":"jq '.[] | select(.test == false)'","input_text":"[{\"id\": 1, \"test\": true}, {\"id\": 2, \"test\": false}, {\"id\": 3, \"test\": \"false\"}]","expected_output":"{\n \"id\": 2,\n \"test\": false\n}\n","validation_input":"[{\"name\": \"a\", \"test\": false}, {\"name\": \"b\", \"test\": true}, {\"name\": \"c\", \"test\": null}]","validation_output":"{\n \"name\": \"a\",\n \"test\": false\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38186594/jq-how-to-select-objects-where-a-field-is-false","question_title":"jq - How to select objects where a field is 'false'?","question_owner":"x3nr0s","answer_owner":"peak","answer_id":38187498,"question_score":19,"reviewed":true} {"id":"so-38186594-p1","request":"Filter an array to include only those objects where the 'test' property is strictly the boolean value false.","command":"jq '.[] | select(.test == false)'","input_text":"[{\"id\": 1, \"test\": true}, {\"id\": 2, \"test\": false}, {\"id\": 3, \"test\": \"false\"}]","expected_output":"{\n \"id\": 2,\n \"test\": false\n}\n","validation_input":"[{\"name\": \"a\", \"test\": false}, {\"name\": \"b\", \"test\": true}, {\"name\": \"c\", \"test\": null}]","validation_output":"{\n \"name\": \"a\",\n \"test\": false\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38186594/jq-how-to-select-objects-where-a-field-is-false","question_title":"jq - How to select objects where a field is 'false'?","question_owner":"x3nr0s","answer_owner":"peak","answer_id":38187498,"question_score":19,"reviewed":true,"paraphrase_of":"so-38186594","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-38459429","request":"Recursively search a JSON object for all non-null values associated with the key 'error'.","command":"jq '.. | .error? // empty'","input_text":"{\n\"A\": { \"error\": null },\n\"B\": { \"C\": {\"error\": \"error string\"}},\n\"C\": { \"D\": {\"error\": null}},\n\"D\": { \"error\": \"err str\"}\n}","expected_output":"\"error string\"\n\"err str\"\n","validation_input":"{\n\"X\": { \"error\": \"fail\" },\n\"Y\": { \"Z\": {\"error\": null}},\n\"W\": { \"error\": \"oops\"}\n}","validation_output":"\"fail\"\n\"oops\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38459429/recursive-search-values-by-key","question_title":"Recursive search values by key","question_owner":"Ardling","answer_owner":"user3899165","answer_id":38460947,"question_score":20,"reviewed":true} {"id":"so-38459429-p1","request":"Perform a recursive search on a JSON object to retrieve all non-null values linked to the key 'error'.","command":"jq '.. | .error? // empty'","input_text":"{\n\"A\": { \"error\": null },\n\"B\": { \"C\": {\"error\": \"error string\"}},\n\"C\": { \"D\": {\"error\": null}},\n\"D\": { \"error\": \"err str\"}\n}","expected_output":"\"error string\"\n\"err str\"\n","validation_input":"{\n\"X\": { \"error\": \"fail\" },\n\"Y\": { \"Z\": {\"error\": null}},\n\"W\": { \"error\": \"oops\"}\n}","validation_output":"\"fail\"\n\"oops\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38459429/recursive-search-values-by-key","question_title":"Recursive search values by key","question_owner":"Ardling","answer_owner":"user3899165","answer_id":38460947,"question_score":20,"reviewed":true,"paraphrase_of":"so-38459429","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-38626762","request":"Remove the \"source\" key from all objects nested directly under the \"b\" key in the input JSON object.","command":"jq '.b[] |= del(.source)'","input_text":"{\"a\":1,\"b\":{\"c\":{\"c1\":\"abc\",\"source\":\"abcxyz\"},\"d\":{\"d1\":\"abcd\",\"source\":\"abcxyz\"}}}","expected_output":"{\n \"a\": 1,\n \"b\": {\n \"c\": {\n \"c1\": \"abc\"\n },\n \"d\": {\n \"d1\": \"abcd\"\n }\n }\n}\n","validation_input":"{\"a\":1,\"b\":{\"x\":{\"x1\":\"val\",\"source\":\"src\"},\"y\":{\"y1\":\"val2\",\"source\":\"src2\"}}}","validation_output":"{\n \"a\": 1,\n \"b\": {\n \"x\": {\n \"x1\": \"val\"\n },\n \"y\": {\n \"y1\": \"val2\"\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38626762/jq-delete-multiple-properties","question_title":"JQ delete multiple properties","question_owner":"Vu Le Anh","answer_owner":"user3899165","answer_id":38657597,"question_score":24,"reviewed":true} {"id":"so-38626762-p1","request":"Delete the 'source' property from every object that is a direct child of the 'b' key in the input JSON.","command":"jq '.b[] |= del(.source)'","input_text":"{\"a\":1,\"b\":{\"c\":{\"c1\":\"abc\",\"source\":\"abcxyz\"},\"d\":{\"d1\":\"abcd\",\"source\":\"abcxyz\"}}}","expected_output":"{\n \"a\": 1,\n \"b\": {\n \"c\": {\n \"c1\": \"abc\"\n },\n \"d\": {\n \"d1\": \"abcd\"\n }\n }\n}\n","validation_input":"{\"a\":1,\"b\":{\"x\":{\"x1\":\"val\",\"source\":\"src\"},\"y\":{\"y1\":\"val2\",\"source\":\"src2\"}}}","validation_output":"{\n \"a\": 1,\n \"b\": {\n \"x\": {\n \"x1\": \"val\"\n },\n \"y\": {\n \"y1\": \"val2\"\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38626762/jq-delete-multiple-properties","question_title":"JQ delete multiple properties","question_owner":"Vu Le Anh","answer_owner":"user3899165","answer_id":38657597,"question_score":24,"reviewed":true,"paraphrase_of":"so-38626762","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-39500608","request":"Remove all keys with null values from a JSON object.","command":"jq 'with_entries(select(.value != null))'","input_text":"{\"a\": 1, \"b\": null, \"c\": 2, \"d\": null}","expected_output":"{\n \"a\": 1,\n \"c\": 2\n}\n","validation_input":"{\"x\": null, \"y\": \"hello\", \"z\": null}","validation_output":"{\n \"y\": \"hello\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39500608/remove-all-null-values","question_title":"Remove all null values","question_owner":"Ela","answer_owner":"peak","answer_id":39501001,"question_score":33,"reviewed":true} {"id":"so-39500608-p1","request":"Strip all keys holding null values from a JSON object.","command":"jq 'with_entries(select(.value != null))'","input_text":"{\"a\": 1, \"b\": null, \"c\": 2, \"d\": null}","expected_output":"{\n \"a\": 1,\n \"c\": 2\n}\n","validation_input":"{\"x\": null, \"y\": \"hello\", \"z\": null}","validation_output":"{\n \"y\": \"hello\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39500608/remove-all-null-values","question_title":"Remove all null values","question_owner":"Ela","answer_owner":"peak","answer_id":39501001,"question_score":33,"reviewed":true,"paraphrase_of":"so-39500608","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-39800718","request":"Find all paths in a nested JSON object that end with the key 'foo'.","command":"jq -c 'paths | select(.[-1] == \"foo\")'","input_text":"{\n \"A\": {\n \"A1\": {\n \"foo\": {\n \"_\": \"_\"\n }\n },\n \"A2\": {\n \"_\": \"_\"\n }\n },\n \"B\": {\n \"B1\": {}\n },\n \"foo\": {\n \"_\": \"_\"\n }\n}","expected_output":"[\"A\",\"A1\",\"foo\"]\n[\"foo\"]\n","validation_input":"{\n \"X\": {\n \"Y\": {\n \"foo\": \"bar\"\n }\n },\n \"Z\": {\n \"foo\": {\n \"nested\": true\n }\n },\n \"other\": \"value\"\n}","validation_output":"[\"X\",\"Y\",\"foo\"]\n[\"Z\",\"foo\"]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39800718/how-to-use-jq-to-find-all-paths-to-a-certain-key","question_title":"How to use jq to find all paths to a certain key","question_owner":"chrisst","answer_owner":"peak","answer_id":39801036,"question_score":27,"reviewed":true} {"id":"so-39800718-p1","request":"Identify every path within a nested JSON object that terminates with the key 'foo'.","command":"jq -c 'paths | select(.[-1] == \"foo\")'","input_text":"{\n \"A\": {\n \"A1\": {\n \"foo\": {\n \"_\": \"_\"\n }\n },\n \"A2\": {\n \"_\": \"_\"\n }\n },\n \"B\": {\n \"B1\": {}\n },\n \"foo\": {\n \"_\": \"_\"\n }\n}","expected_output":"[\"A\",\"A1\",\"foo\"]\n[\"foo\"]\n","validation_input":"{\n \"X\": {\n \"Y\": {\n \"foo\": \"bar\"\n }\n },\n \"Z\": {\n \"foo\": {\n \"nested\": true\n }\n },\n \"other\": \"value\"\n}","validation_output":"[\"X\",\"Y\",\"foo\"]\n[\"Z\",\"foo\"]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39800718/how-to-use-jq-to-find-all-paths-to-a-certain-key","question_title":"How to use jq to find all paths to a certain key","question_owner":"chrisst","answer_owner":"peak","answer_id":39801036,"question_score":27,"reviewed":true,"paraphrase_of":"so-39800718","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-40321035","request":"Extract the message field from the content object and remove all newline and tab characters from it.","command":"jq -r '.content.message | gsub(\"[\\n\\t]\"; \"\")'","input_text":"{\"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\"}}","expected_output":"ERROR LALALLAERROR INFO NANANANSOME MORE ERROR INFOBABABABABABBA BABABABA ABABBABAA BABABABAB\n","validation_input":"{\"HOSTNAME\":\"server2.example\",\"level\":\"INFO\",\"level_value\":20000,\"logger_name\":\"server2.example.app\",\"content\":{\"message\":\"Start\\tProcess\\nEnd\\n\"}}","validation_output":"StartProcessEnd\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40321035/remove-escape-sequence-characters-like-newline-tab-and-carriage-return-from-jso","question_title":"Remove escape sequence characters like newline, tab and carriage return from JSON file","question_owner":"user3792699","answer_owner":"mklement0","answer_id":40322380,"question_score":19,"reviewed":true} {"id":"so-40321035-p1","request":"Retrieve the 'message' field from the 'content' object and strip out all newline and tab characters.","command":"jq -r '.content.message | gsub(\"[\\n\\t]\"; \"\")'","input_text":"{\"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\"}}","expected_output":"ERROR LALALLAERROR INFO NANANANSOME MORE ERROR INFOBABABABABABBA BABABABA ABABBABAA BABABABAB\n","validation_input":"{\"HOSTNAME\":\"server2.example\",\"level\":\"INFO\",\"level_value\":20000,\"logger_name\":\"server2.example.app\",\"content\":{\"message\":\"Start\\tProcess\\nEnd\\n\"}}","validation_output":"StartProcessEnd\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40321035/remove-escape-sequence-characters-like-newline-tab-and-carriage-return-from-jso","question_title":"Remove escape sequence characters like newline, tab and carriage return from JSON file","question_owner":"user3792699","answer_owner":"mklement0","answer_id":40322380,"question_score":19,"reviewed":true,"paraphrase_of":"so-40321035","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-40847936","request":"Swap the keys and values of a JSON object so that original values become keys and original keys become values.","command":"jq 'to_entries | map({(.value): .key}) | add'","input_text":"{\"123\": \"Foobar\", \"567\": \"Poit\"}","expected_output":"{\n \"Foobar\": \"123\",\n \"Poit\": \"567\"\n}\n","validation_input":"{\"abc\": \"xyz\", \"def\": \"uvw\"}","validation_output":"{\n \"xyz\": \"abc\",\n \"uvw\": \"def\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40847936/how-to-swap-key-and-value-of-an-object-using-jq","question_title":"How to swap key and value of an object using jq?","question_owner":"k0pernikus","answer_owner":"peak","answer_id":40849180,"question_score":18,"reviewed":true} {"id":"so-40847936-p1","request":"Invert a JSON object by swapping its keys and values, making the original values the new keys and vice versa.","command":"jq 'to_entries | map({(.value): .key}) | add'","input_text":"{\"123\": \"Foobar\", \"567\": \"Poit\"}","expected_output":"{\n \"Foobar\": \"123\",\n \"Poit\": \"567\"\n}\n","validation_input":"{\"abc\": \"xyz\", \"def\": \"uvw\"}","validation_output":"{\n \"xyz\": \"abc\",\n \"uvw\": \"def\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40847936/how-to-swap-key-and-value-of-an-object-using-jq","question_title":"How to swap key and value of an object using jq?","question_owner":"k0pernikus","answer_owner":"peak","answer_id":40849180,"question_score":18,"reviewed":true,"paraphrase_of":"so-40847936","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-40923539","request":"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.","command":"jq '.activities | with_entries(select(.value | has(\"stop_time_utc\"))) | keys'","input_text":"{\"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\"}}}","expected_output":"[\n \"-KSndgjqvmQkWVKHCpLh\",\n \"-KSptboGjo8g4bieUbGM\"\n]\n","validation_input":"{\"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\"}}}","validation_output":"[\n \"act2\",\n \"act3\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40923539/jq-filtering-for-keys","question_title":"JQ: Filtering for keys","question_owner":"DThimsen","answer_owner":"peak","answer_id":40924154,"question_score":22,"reviewed":true} {"id":"so-40923539-p1","request":"From an object with an 'activities' field, filter for entries containing a 'stop_time_utc' key and return an array of their keys.","command":"jq '.activities | with_entries(select(.value | has(\"stop_time_utc\"))) | keys'","input_text":"{\"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\"}}}","expected_output":"[\n \"-KSndgjqvmQkWVKHCpLh\",\n \"-KSptboGjo8g4bieUbGM\"\n]\n","validation_input":"{\"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\"}}}","validation_output":"[\n \"act2\",\n \"act3\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40923539/jq-filtering-for-keys","question_title":"JQ: Filtering for keys","question_owner":"DThimsen","answer_owner":"peak","answer_id":40924154,"question_score":22,"reviewed":true,"paraphrase_of":"so-40923539","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41712363","request":"Extract the value associated with the key \"storage_server.disk_total\" from the \"stats\" object in the provided JSON.","command":"jq '.stats[\"storage_server.disk_total\"]'","input_text":"{\n \"stats\": {\n \"storage_server.disk_total\": 50000000000\n },\n \"counters\": {}\n}","expected_output":"50000000000\n","validation_input":"{\n \"stats\": {\n \"storage_server.disk_total\": 123456789\n },\n \"counters\": {\n \"read\": 100\n }\n}","validation_output":"123456789\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41712363/basic-jq-usage-how-to-get-nested-value","question_title":"Basic jq usage. How to get nested value","question_owner":"nullUser","answer_owner":"peak","answer_id":41713087,"question_score":30,"reviewed":true} {"id":"so-41712363-p1","request":"Retrieve the value for the key 'storage_server.disk_total' located within the 'stats' object of the given JSON.","command":"jq '.stats[\"storage_server.disk_total\"]'","input_text":"{\n \"stats\": {\n \"storage_server.disk_total\": 50000000000\n },\n \"counters\": {}\n}","expected_output":"50000000000\n","validation_input":"{\n \"stats\": {\n \"storage_server.disk_total\": 123456789\n },\n \"counters\": {\n \"read\": 100\n }\n}","validation_output":"123456789\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41712363/basic-jq-usage-how-to-get-nested-value","question_title":"Basic jq usage. How to get nested value","question_owner":"nullUser","answer_owner":"peak","answer_id":41713087,"question_score":30,"reviewed":true,"paraphrase_of":"so-41712363","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41958475","request":"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.","command":"jq 'map(.name == \"something\") | index(true)'","input_text":"[\n {\"name\": \"1\", \"urgent\": false},\n {\"name\": \"2\", \"urgent\": false},\n {\"name\": \"something\", \"urgent\": false}\n]","expected_output":"2\n","validation_input":"[\n {\"name\": \"alpha\", \"urgent\": true},\n {\"name\": \"beta\", \"urgent\": false},\n {\"name\": \"gamma\", \"urgent\": false}\n]","validation_output":"null\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41958475/getting-the-object-array-index-in-jq","question_title":"Getting the object array index in jq","question_owner":"xeor","answer_owner":"JimD.","answer_id":41958933,"question_score":31,"reviewed":true} {"id":"so-41958475-p1","request":"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.","command":"jq 'map(.name == \"something\") | index(true)'","input_text":"[\n {\"name\": \"1\", \"urgent\": false},\n {\"name\": \"2\", \"urgent\": false},\n {\"name\": \"something\", \"urgent\": false}\n]","expected_output":"2\n","validation_input":"[\n {\"name\": \"alpha\", \"urgent\": true},\n {\"name\": \"beta\", \"urgent\": false},\n {\"name\": \"gamma\", \"urgent\": false}\n]","validation_output":"null\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41958475/getting-the-object-array-index-in-jq","question_title":"Getting the object array index in jq","question_owner":"xeor","answer_owner":"JimD.","answer_id":41958933,"question_score":31,"reviewed":true,"paraphrase_of":"so-41958475","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-43842672","request":"Extract the value of the 'CloudSanityPassed' field from the 'properties' object in the provided JSON.","command":"jq '.properties.CloudSanityPassed'","input_text":"{\n \"properties\": {\n \"CloudSanityPassed\": [\"true\"],\n \"GITCOMMIT\": [\"test1\"],\n \"buildNumber\": [\"54\"],\n \"jobName\": [\"InveergDB-UI\"]\n },\n \"uri\": \"http://example.com/file.zip\"\n}","expected_output":"[\n \"true\"\n]\n","validation_input":"{\n \"properties\": {\n \"CloudSanityPassed\": [\"false\"],\n \"GITCOMMIT\": [\"abc\"],\n \"buildNumber\": [\"99\"],\n \"jobName\": [\"TestJob\"]\n },\n \"uri\": \"http://example.com/other.zip\"\n}","validation_output":"[\n \"false\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43842672/jq-cannot-index-string-with-string","question_title":"jq - Cannot index string with string","question_owner":"dice2011","answer_owner":"ymonad","answer_id":43842886,"question_score":32,"reviewed":true} {"id":"so-43842672-p1","request":"Obtain the value of the 'CloudSanityPassed' property from the 'properties' object in the supplied JSON.","command":"jq '.properties.CloudSanityPassed'","input_text":"{\n \"properties\": {\n \"CloudSanityPassed\": [\"true\"],\n \"GITCOMMIT\": [\"test1\"],\n \"buildNumber\": [\"54\"],\n \"jobName\": [\"InveergDB-UI\"]\n },\n \"uri\": \"http://example.com/file.zip\"\n}","expected_output":"[\n \"true\"\n]\n","validation_input":"{\n \"properties\": {\n \"CloudSanityPassed\": [\"false\"],\n \"GITCOMMIT\": [\"abc\"],\n \"buildNumber\": [\"99\"],\n \"jobName\": [\"TestJob\"]\n },\n \"uri\": \"http://example.com/other.zip\"\n}","validation_output":"[\n \"false\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43842672/jq-cannot-index-string-with-string","question_title":"jq - Cannot index string with string","question_owner":"dice2011","answer_owner":"ymonad","answer_id":43842886,"question_score":32,"reviewed":true,"paraphrase_of":"so-43842672","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44288635","request":"Remove empty strings from a JSON array of strings.","command":"jq 'map(select(length > 0))'","input_text":"[\"bob\", \"\", \"tim\", \"\"]\n[\"\", \"alice\", \"\", \"charlie\", \"\"]","expected_output":"[\n \"bob\",\n \"tim\"\n]\n[\n \"alice\",\n \"charlie\"\n]\n","validation_input":"[\n [\"bob\", \"tim\"],\n [\"alice\", \"charlie\"]\n]","validation_output":"[\n [\n \"bob\",\n \"tim\"\n ],\n [\n \"alice\",\n \"charlie\"\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44288635/remove-blank-strings-from-array-with-jq","question_title":"Remove blank strings from array with jq?","question_owner":"leeand00","answer_owner":"user197693","answer_id":44289083,"question_score":21,"reviewed":true} {"id":"so-44288635-p1","request":"Filter out empty strings from a JSON string array.","command":"jq 'map(select(length > 0))'","input_text":"[\"bob\", \"\", \"tim\", \"\"]\n[\"\", \"alice\", \"\", \"charlie\", \"\"]","expected_output":"[\n \"bob\",\n \"tim\"\n]\n[\n \"alice\",\n \"charlie\"\n]\n","validation_input":"[\n [\"bob\", \"tim\"],\n [\"alice\", \"charlie\"]\n]","validation_output":"[\n [\n \"bob\",\n \"tim\"\n ],\n [\n \"alice\",\n \"charlie\"\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44288635/remove-blank-strings-from-array-with-jq","question_title":"Remove blank strings from array with jq?","question_owner":"leeand00","answer_owner":"user197693","answer_id":44289083,"question_score":21,"reviewed":true,"paraphrase_of":"so-44288635","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44704404","request":"Select JSON objects from a stream where the 'author' field matches any value in a specified whitelist array.","command":"jq -s '[.[] | select(.author as $a | [\"Gary\", \"Larry\"] | index($a))]'","input_text":"{\"author\": \"Gary\", \"text\": \"Blah\"}\n{\"author\": \"Larry\", \"text\": \"More Blah\"}\n{\"author\": \"Jerry\", \"text\": \"Yet more Blah\"}","expected_output":"[\n {\n \"author\": \"Gary\",\n \"text\": \"Blah\"\n },\n {\n \"author\": \"Larry\",\n \"text\": \"More Blah\"\n }\n]\n","validation_input":"{\"author\": \"Barry\", \"text\": \"Even more Blah\"}\n{\"author\": \"Teri\", \"text\": \"Text on text on text\"}\n{\"author\": \"Bob\", \"text\": \"Another thing to say\"}","validation_output":"[]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44704404/select-entries-based-on-multiple-values-in-jq","question_title":"Select entries based on multiple values in jq","question_owner":"DGaff","answer_owner":"peak","answer_id":44707560,"question_score":20,"reviewed":true} {"id":"so-44704404-p1","request":"From a JSON stream, select objects whose 'author' field matches any entry in a given whitelist array.","command":"jq -s '[.[] | select(.author as $a | [\"Gary\", \"Larry\"] | index($a))]'","input_text":"{\"author\": \"Gary\", \"text\": \"Blah\"}\n{\"author\": \"Larry\", \"text\": \"More Blah\"}\n{\"author\": \"Jerry\", \"text\": \"Yet more Blah\"}","expected_output":"[\n {\n \"author\": \"Gary\",\n \"text\": \"Blah\"\n },\n {\n \"author\": \"Larry\",\n \"text\": \"More Blah\"\n }\n]\n","validation_input":"{\"author\": \"Barry\", \"text\": \"Even more Blah\"}\n{\"author\": \"Teri\", \"text\": \"Text on text on text\"}\n{\"author\": \"Bob\", \"text\": \"Another thing to say\"}","validation_output":"[]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44704404/select-entries-based-on-multiple-values-in-jq","question_title":"Select entries based on multiple values in jq","question_owner":"DGaff","answer_owner":"peak","answer_id":44707560,"question_score":20,"reviewed":true,"paraphrase_of":"so-44704404","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-45170897","request":"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.","command":"jq -s '[.[] | .Properties.ItmId] | group_by(.) | map({(.[0]): length}) | add'","input_text":"{\"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"1694738780\"}}\n{\"ReferringUrl\": \"L\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"1347809133\"}}\n{\"ReferringUrl\": \"M\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"1694738780\"}}","expected_output":"{\n \"1347809133\": 1,\n \"1694738780\": 2\n}\n","validation_input":"{\"ReferringUrl\": \"A\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"111\"}}\n{\"ReferringUrl\": \"B\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"222\"}}\n{\"ReferringUrl\": \"C\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"111\"}}\n{\"ReferringUrl\": \"D\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"333\"}}","validation_output":"{\n \"111\": 2,\n \"222\": 1,\n \"333\": 1\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45170897/jq-count-the-number-of-items-in-json-by-a-specific-key","question_title":"jq count the number of items in json by a specific key","question_owner":"Eleanor","answer_owner":"peak","answer_id":45171347,"question_score":35,"reviewed":true} {"id":"so-45170897-p1","request":"Tally the frequency of each ItmId within the Properties object of a JSON stream and return a mapping of ItmId to count.","command":"jq -s '[.[] | .Properties.ItmId] | group_by(.) | map({(.[0]): length}) | add'","input_text":"{\"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"1694738780\"}}\n{\"ReferringUrl\": \"L\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"1347809133\"}}\n{\"ReferringUrl\": \"M\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"1694738780\"}}","expected_output":"{\n \"1347809133\": 1,\n \"1694738780\": 2\n}\n","validation_input":"{\"ReferringUrl\": \"A\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"111\"}}\n{\"ReferringUrl\": \"B\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"222\"}}\n{\"ReferringUrl\": \"C\", \"OpenAccess\": \"1\", \"Properties\": {\"ItmId\": \"111\"}}\n{\"ReferringUrl\": \"D\", \"OpenAccess\": \"0\", \"Properties\": {\"ItmId\": \"333\"}}","validation_output":"{\n \"111\": 2,\n \"222\": 1,\n \"333\": 1\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45170897/jq-count-the-number-of-items-in-json-by-a-specific-key","question_title":"jq count the number of items in json by a specific key","question_owner":"Eleanor","answer_owner":"peak","answer_id":45171347,"question_score":35,"reviewed":true,"paraphrase_of":"so-45170897","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-45979477","request":"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.","command":"jq '.cruises[].waypoint_cities | first, last'","input_text":"{\"cruises\": [{\"waypoint_cities\": [\"Palma de Mallorca\", \"Cádiz\", \"Barcelona\"]}]}","expected_output":"\"Palma de Mallorca\"\n\"Barcelona\"\n","validation_input":"{\"cruises\": [{\"waypoint_cities\": [\"A\", \"B\", \"C\", \"D\"]}, {\"waypoint_cities\": [\"X\", \"Y\"]}]}","validation_output":"\"A\"\n\"D\"\n\"X\"\n\"Y\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45979477/extract-the-first-and-the-last-value-of-a-json-array-object","question_title":"Extract the first and the last value of a json array/object","question_owner":"TimoC","answer_owner":"jq170727","answer_id":45986265,"question_score":36,"reviewed":true} {"id":"so-45979477-p1","request":"For each cruise in a JSON object's 'cruises' array, extract the first and last city from its 'waypoint_cities' list.","command":"jq '.cruises[].waypoint_cities | first, last'","input_text":"{\"cruises\": [{\"waypoint_cities\": [\"Palma de Mallorca\", \"Cádiz\", \"Barcelona\"]}]}","expected_output":"\"Palma de Mallorca\"\n\"Barcelona\"\n","validation_input":"{\"cruises\": [{\"waypoint_cities\": [\"A\", \"B\", \"C\", \"D\"]}, {\"waypoint_cities\": [\"X\", \"Y\"]}]}","validation_output":"\"A\"\n\"D\"\n\"X\"\n\"Y\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45979477/extract-the-first-and-the-last-value-of-a-json-array-object","question_title":"Extract the first and the last value of a json array/object","question_owner":"TimoC","answer_owner":"jq170727","answer_id":45986265,"question_score":36,"reviewed":true,"paraphrase_of":"so-45979477","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-46460631","request":"Count the total number of non-null resources across all modules in the JSON object.","command":"jq '[.modules[].resources | select(.[] != null)] | length'","input_text":"{\n \"modules\": [\n {\n \"resources\": [\n { \"name\": \"res1\" },\n null,\n { \"name\": \"res2\" }\n ]\n },\n {\n \"resources\": [\n { \"name\": \"res3\" }\n ]\n }\n ]\n}","expected_output":"3\n","validation_input":"{\n \"modules\": [\n {\n \"resources\": [\n null,\n { \"name\": \"a\" }\n ]\n },\n {\n \"resources\": [\n { \"name\": \"b\" },\n { \"name\": \"c\" },\n null\n ]\n },\n {\n \"resources\": []\n }\n ]\n}","validation_output":"3\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46460631/how-can-i-count-number-of-elements-after-query","question_title":"How can I count number of elements after query?","question_owner":"Konstantin Shestakov","answer_owner":"hek2mgl","answer_id":46460707,"question_score":20,"reviewed":true} {"id":"so-46460631-p1","request":"Calculate the total count of non-null resources across all modules in a JSON object.","command":"jq '[.modules[].resources | select(.[] != null)] | length'","input_text":"{\n \"modules\": [\n {\n \"resources\": [\n { \"name\": \"res1\" },\n null,\n { \"name\": \"res2\" }\n ]\n },\n {\n \"resources\": [\n { \"name\": \"res3\" }\n ]\n }\n ]\n}","expected_output":"3\n","validation_input":"{\n \"modules\": [\n {\n \"resources\": [\n null,\n { \"name\": \"a\" }\n ]\n },\n {\n \"resources\": [\n { \"name\": \"b\" },\n { \"name\": \"c\" },\n null\n ]\n },\n {\n \"resources\": []\n }\n ]\n}","validation_output":"3\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46460631/how-can-i-count-number-of-elements-after-query","question_title":"How can I count number of elements after query?","question_owner":"Konstantin Shestakov","answer_owner":"hek2mgl","answer_id":46460707,"question_score":20,"reviewed":true,"paraphrase_of":"so-46460631","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-46530167","request":"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.","command":"jq '.[] | select(.id == \"1\" or .id == \"2\") | .name, .value'","input_text":"[\n {\n \"id\": \"1\",\n \"name\": \"sausage\",\n \"value\": 100\n },\n {\n \"id\": \"2\",\n \"name\": \"spam\",\n \"value\": 200\n },\n {\n \"id\": \"3\",\n \"name\": \"eggs\",\n \"value\": 300\n }\n]","expected_output":"\"sausage\"\n100\n\"spam\"\n200\n","validation_input":"[\n {\n \"id\": \"1\",\n \"name\": \"apple\",\n \"value\": 10\n },\n {\n \"id\": \"2\",\n \"name\": \"banana\",\n \"value\": 20\n },\n {\n \"id\": \"3\",\n \"name\": \"cherry\",\n \"value\": 30\n },\n {\n \"id\": \"4\",\n \"name\": \"date\",\n \"value\": 40\n }\n]","validation_output":"\"apple\"\n10\n\"banana\"\n20\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46530167/jq-select-filter-with-multiple-arguments","question_title":"JQ select filter with multiple arguments","question_owner":"ccpizza","answer_owner":"bhansa","answer_id":46530324,"question_score":20,"reviewed":true} {"id":"so-46530167-p1","request":"Keep only JSON objects with id \"1\" or \"2\", then print their name and value fields on separate lines.","command":"jq '.[] | select(.id == \"1\" or .id == \"2\") | .name, .value'","input_text":"[\n {\n \"id\": \"1\",\n \"name\": \"sausage\",\n \"value\": 100\n },\n {\n \"id\": \"2\",\n \"name\": \"spam\",\n \"value\": 200\n },\n {\n \"id\": \"3\",\n \"name\": \"eggs\",\n \"value\": 300\n }\n]","expected_output":"\"sausage\"\n100\n\"spam\"\n200\n","validation_input":"[\n {\n \"id\": \"1\",\n \"name\": \"apple\",\n \"value\": 10\n },\n {\n \"id\": \"2\",\n \"name\": \"banana\",\n \"value\": 20\n },\n {\n \"id\": \"3\",\n \"name\": \"cherry\",\n \"value\": 30\n },\n {\n \"id\": \"4\",\n \"name\": \"date\",\n \"value\": 40\n }\n]","validation_output":"\"apple\"\n10\n\"banana\"\n20\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46530167/jq-select-filter-with-multiple-arguments","question_title":"JQ select filter with multiple arguments","question_owner":"ccpizza","answer_owner":"bhansa","answer_id":46530324,"question_score":20,"reviewed":true,"paraphrase_of":"so-46530167","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-46564720","request":"Generate a JSON array containing the dot-separated paths of all keys in the input JSON object.","command":"jq '[paths | join(\".\")]'","input_text":"{\"a\":1,\"b\":{\"c\":2}}","expected_output":"[\n \"a\",\n \"b\",\n \"b.c\"\n]\n","validation_input":"{\"x\":10,\"y\":{\"z\":{\"w\":5}}}","validation_output":"[\n \"x\",\n \"y\",\n \"y.z\",\n \"y.z.w\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46564720/how-to-extract-all-also-nested-key-names-with-jq","question_title":"How to extract all (also nested) key names with jq","question_owner":"wjtk","answer_owner":"RomanPerekhrest","answer_id":46565894,"question_score":24,"reviewed":true} {"id":"so-46564720-p1","request":"Produce a JSON array listing the dot-separated paths for every key in the input JSON object.","command":"jq '[paths | join(\".\")]'","input_text":"{\"a\":1,\"b\":{\"c\":2}}","expected_output":"[\n \"a\",\n \"b\",\n \"b.c\"\n]\n","validation_input":"{\"x\":10,\"y\":{\"z\":{\"w\":5}}}","validation_output":"[\n \"x\",\n \"y\",\n \"y.z\",\n \"y.z.w\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46564720/how-to-extract-all-also-nested-key-names-with-jq","question_title":"How to extract all (also nested) key names with jq","question_owner":"wjtk","answer_owner":"RomanPerekhrest","answer_id":46565894,"question_score":24,"reviewed":true,"paraphrase_of":"so-46564720","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-46911763","request":"From the array of objects, find the object where the name is \"AAA\" and output its members and id values separated by a space.","command":"jq -r '.[] | select(.name==\"AAA\") | \"\\(.members) \\(.id)\"'","input_text":"[\n {\n \"name\": \"AAA\",\n \"members\": 10,\n \"profiles\": 0,\n \"templates\": 0,\n \"ldapGroups\": 0,\n \"ldapMembers\": 0,\n \"id\": \"20\"\n },\n {\n \"name\": \"BBB\",\n \"members\": 5,\n \"id\": \"30\"\n }\n]","expected_output":"10 20\n","validation_input":"[\n {\n \"name\": \"CCC\",\n \"members\": 1,\n \"id\": \"1\"\n },\n {\n \"name\": \"AAA\",\n \"members\": 99,\n \"profiles\": 5,\n \"templates\": 2,\n \"ldapGroups\": 1,\n \"ldapMembers\": 0,\n \"id\": \"999\"\n }\n]","validation_output":"99 999\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46911763/jq-error-number-and-string-cannot-be-added","question_title":"jq: error: number and string cannot be added","question_owner":"Chris","answer_owner":"hek2mgl","answer_id":46912879,"question_score":29,"reviewed":true} {"id":"so-46911763-p1","request":"Locate the object with name \"AAA\" in an array and output its members and id separated by a space.","command":"jq -r '.[] | select(.name==\"AAA\") | \"\\(.members) \\(.id)\"'","input_text":"[\n {\n \"name\": \"AAA\",\n \"members\": 10,\n \"profiles\": 0,\n \"templates\": 0,\n \"ldapGroups\": 0,\n \"ldapMembers\": 0,\n \"id\": \"20\"\n },\n {\n \"name\": \"BBB\",\n \"members\": 5,\n \"id\": \"30\"\n }\n]","expected_output":"10 20\n","validation_input":"[\n {\n \"name\": \"CCC\",\n \"members\": 1,\n \"id\": \"1\"\n },\n {\n \"name\": \"AAA\",\n \"members\": 99,\n \"profiles\": 5,\n \"templates\": 2,\n \"ldapGroups\": 1,\n \"ldapMembers\": 0,\n \"id\": \"999\"\n }\n]","validation_output":"99 999\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46911763/jq-error-number-and-string-cannot-be-added","question_title":"jq: error: number and string cannot be added","question_owner":"Chris","answer_owner":"hek2mgl","answer_id":46912879,"question_score":29,"reviewed":true,"paraphrase_of":"so-46911763","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47355901","request":"Update the values of keys 'two' and 'three' in a JSON object to 'newval' while preserving all other keys.","command":"jq '. + {two: \"newval\", three: \"newval\"}'","input_text":"{\n \"one\": {\n \"val\": 1\n },\n \"two\": \"val\",\n \"three\": \"val\",\n \"four\": \"val\"\n}","expected_output":"{\n \"one\": {\n \"val\": 1\n },\n \"two\": \"newval\",\n \"three\": \"newval\",\n \"four\": \"val\"\n}\n","validation_input":"{\n \"alpha\": 10,\n \"two\": \"old\",\n \"three\": \"old\",\n \"beta\": 20\n}","validation_output":"{\n \"alpha\": 10,\n \"two\": \"newval\",\n \"three\": \"newval\",\n \"beta\": 20\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47355901/jq-change-multiple-values","question_title":"jq: Change multiple values","question_owner":"OrangePot","answer_owner":"jq170727","answer_id":47357956,"question_score":34,"reviewed":true} {"id":"so-47355901-p1","request":"Set the values for keys 'two' and 'three' to 'newval' in a JSON object, leaving other keys unchanged.","command":"jq '. + {two: \"newval\", three: \"newval\"}'","input_text":"{\n \"one\": {\n \"val\": 1\n },\n \"two\": \"val\",\n \"three\": \"val\",\n \"four\": \"val\"\n}","expected_output":"{\n \"one\": {\n \"val\": 1\n },\n \"two\": \"newval\",\n \"three\": \"newval\",\n \"four\": \"val\"\n}\n","validation_input":"{\n \"alpha\": 10,\n \"two\": \"old\",\n \"three\": \"old\",\n \"beta\": 20\n}","validation_output":"{\n \"alpha\": 10,\n \"two\": \"newval\",\n \"three\": \"newval\",\n \"beta\": 20\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47355901/jq-change-multiple-values","question_title":"jq: Change multiple values","question_owner":"OrangePot","answer_owner":"jq170727","answer_id":47357956,"question_score":34,"reviewed":true,"paraphrase_of":"so-47355901","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48529016","request":"Remove the key \"maxHeight\" from a JSON object if it exists, preserving the rest of the structure.","command":"jq 'del(.maxHeight)'","input_text":"{\n \"style\": {\n \"className\": \"feature\"\n },\n \"maxHeight\": \"200px\",\n \"label\": \"test\"\n}","expected_output":"{\n \"style\": {\n \"className\": \"feature\"\n },\n \"label\": \"test\"\n}\n","validation_input":"{\n \"id\": 1,\n \"maxHeight\": \"100px\",\n \"name\": \"example\"\n}","validation_output":"{\n \"id\": 1,\n \"name\": \"example\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48529016/remove-a-keyvalue-from-an-json-object-using-jq","question_title":"Remove a key:value from an JSON object using jq","question_owner":"MostlyRquestions","answer_owner":"exic","answer_id":60723320,"question_score":26,"reviewed":true} {"id":"so-48529016-p1","request":"Delete the \"maxHeight\" key from a JSON object if present, keeping the remaining structure intact.","command":"jq 'del(.maxHeight)'","input_text":"{\n \"style\": {\n \"className\": \"feature\"\n },\n \"maxHeight\": \"200px\",\n \"label\": \"test\"\n}","expected_output":"{\n \"style\": {\n \"className\": \"feature\"\n },\n \"label\": \"test\"\n}\n","validation_input":"{\n \"id\": 1,\n \"maxHeight\": \"100px\",\n \"name\": \"example\"\n}","validation_output":"{\n \"id\": 1,\n \"name\": \"example\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48529016/remove-a-keyvalue-from-an-json-object-using-jq","question_title":"Remove a key:value from an JSON object using jq","question_owner":"MostlyRquestions","answer_owner":"exic","answer_id":60723320,"question_score":26,"reviewed":true,"paraphrase_of":"so-48529016","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-49181898","request":"Convert the LastModified timestamp string to a Unix epoch integer by removing milliseconds and parsing the date.","command":"jq '.LastModified |= (sub(\"\\\\.000Z\";\"Z\") | fromdate)'","input_text":"{\"LastModified\": \"2018-03-07T17:24:33.000Z\", \"Key\": \"pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json\"}","expected_output":"{\n \"LastModified\": 1520443473,\n \"Key\": \"pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json\"\n}\n","validation_input":"{\"LastModified\": \"2020-01-01T12:00:00.000Z\", \"Key\": \"data/file.json\"}","validation_output":"{\n \"LastModified\": 1577880000,\n \"Key\": \"data/file.json\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49181898/jq-replace-part-of-value-in-json","question_title":"jq replace part of value in json","question_owner":"Ryan Loeffler","answer_owner":"RomanPerekhrest","answer_id":49182262,"question_score":19,"reviewed":true} {"id":"so-49181898-p1","request":"Parse the LastModified timestamp string into a Unix epoch integer by stripping milliseconds.","command":"jq '.LastModified |= (sub(\"\\\\.000Z\";\"Z\") | fromdate)'","input_text":"{\"LastModified\": \"2018-03-07T17:24:33.000Z\", \"Key\": \"pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json\"}","expected_output":"{\n \"LastModified\": 1520443473,\n \"Key\": \"pending/archive/f7ab1684-e94d-483e-ace1-560367c1196c_1000_s.json\"\n}\n","validation_input":"{\"LastModified\": \"2020-01-01T12:00:00.000Z\", \"Key\": \"data/file.json\"}","validation_output":"{\n \"LastModified\": 1577880000,\n \"Key\": \"data/file.json\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49181898/jq-replace-part-of-value-in-json","question_title":"jq replace part of value in json","question_owner":"Ryan Loeffler","answer_owner":"RomanPerekhrest","answer_id":49182262,"question_score":19,"reviewed":true,"paraphrase_of":"so-49181898","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-50286066","request":"Decode all base64-encoded values in the 'data' object of a Kubernetes Secret JSON and output the resulting key-value pairs.","command":"jq '.data | map_values(@base64d)'","input_text":"{\n \"apiVersion\": \"v1\",\n \"kind\": \"Secret\",\n \"metadata\": {\n \"name\": \"testsecret\"\n },\n \"data\": {\n \"key1\": \"dmFsMQ==\",\n \"key2\": \"dmFsMg==\"\n }\n}","expected_output":"{\n \"key1\": \"val1\",\n \"key2\": \"val2\"\n}\n","validation_input":"{\n \"apiVersion\": \"v1\",\n \"kind\": \"Secret\",\n \"metadata\": {\n \"name\": \"anothersecret\"\n },\n \"data\": {\n \"username\": \"YWRtaW4=\",\n \"password\": \"cGFzc3dvcmQxMjM=\"\n }\n}","validation_output":"{\n \"username\": \"admin\",\n \"password\": \"password123\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50286066/kubernetes-kubectl-print-all-secrets","question_title":"Kubernetes / kubectl print all secrets","question_owner":"s g","answer_owner":"peak","answer_id":50286402,"question_score":27,"reviewed":true} {"id":"so-51494389","request":"Extract the value of the key \"@def-ghi\" located inside the \"abc\" object from the input JSON.","command":"jq '.abc.\"@def-ghi\"'","input_text":"{\"abc\":{\"@def-ghi\":\"value1\",\"xyz\":\"value2\"}}","expected_output":"\"value1\"\n","validation_input":"{\"abc\":{\"@def-ghi\":\"another_value\",\"other\":\"data\"}}","validation_output":"\"another_value\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51494389/escape-field-name-in-jq-that-contains-and","question_title":"Escape field name in jq that contains '@' and '-'?","question_owner":"shadyabhi","answer_owner":"chepner","answer_id":51502506,"question_score":24,"reviewed":true} {"id":"so-51494389-p1","request":"Retrieve the value associated with the key \"@def-ghi\" within the \"abc\" object of the input JSON.","command":"jq '.abc.\"@def-ghi\"'","input_text":"{\"abc\":{\"@def-ghi\":\"value1\",\"xyz\":\"value2\"}}","expected_output":"\"value1\"\n","validation_input":"{\"abc\":{\"@def-ghi\":\"another_value\",\"other\":\"data\"}}","validation_output":"\"another_value\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51494389/escape-field-name-in-jq-that-contains-and","question_title":"Escape field name in jq that contains '@' and '-'?","question_owner":"shadyabhi","answer_owner":"chepner","answer_id":51502506,"question_score":24,"reviewed":true,"paraphrase_of":"so-51494389","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51837624","request":"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.","command":"jq '.basePath = (.version | split(\".\") | if .[0] == \"0\" then \"beta\" + .[1] else .[0] end)'","input_text":"{\"version\": \"0.1.2\", \"basePath\": \"/\"}","expected_output":"{\n \"version\": \"0.1.2\",\n \"basePath\": \"beta1\"\n}\n","validation_input":"{\"version\": \"1.2.3\", \"basePath\": \"/\"}","validation_output":"{\n \"version\": \"1.2.3\",\n \"basePath\": \"1\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51837624/jq-split-string-and-assign","question_title":"jq split string and assign","question_owner":"Rizwan Saeed","answer_owner":"peak","answer_id":51837735,"question_score":19,"reviewed":true} {"id":"so-51837624-p1","request":"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.","command":"jq '.basePath = (.version | split(\".\") | if .[0] == \"0\" then \"beta\" + .[1] else .[0] end)'","input_text":"{\"version\": \"0.1.2\", \"basePath\": \"/\"}","expected_output":"{\n \"version\": \"0.1.2\",\n \"basePath\": \"beta1\"\n}\n","validation_input":"{\"version\": \"1.2.3\", \"basePath\": \"/\"}","validation_output":"{\n \"version\": \"1.2.3\",\n \"basePath\": \"1\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51837624/jq-split-string-and-assign","question_title":"jq split string and assign","question_owner":"Rizwan Saeed","answer_owner":"peak","answer_id":51837735,"question_score":19,"reviewed":true,"paraphrase_of":"so-51837624","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-56355822","request":"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.","command":"jq '.details.addresses[][] | select(.version == 4).addr'","input_text":"{\n \"details\": {\n \"car\": \"bmw\",\n \"addresses\": {\n \"ext-118-21-8-0-29\": [\n {\n \"version\": 4,\n \"addr\": \"89 Psr\"\n },\n {\n \"version\": 6,\n \"addr\": \"56 apT\"\n }\n ]\n }\n }\n}","expected_output":"\"89 Psr\"\n","validation_input":"{\n \"details\": {\n \"car\": \"audi\",\n \"addresses\": {\n \"dynamic-key-123\": [\n {\n \"version\": 6,\n \"addr\": \"::1\"\n },\n {\n \"version\": 4,\n \"addr\": \"192.168.1.1\"\n }\n ]\n }\n }\n}","validation_output":"\"192.168.1.1\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56355822/how-to-use-jq-wildcard","question_title":"How to use jq wildcard","question_owner":"executable","answer_owner":"Jeff Mercado","answer_id":56356012,"question_score":28,"reviewed":true} {"id":"so-56355822-p1","request":"Locate the address entry with version 4 within the dynamically keyed addresses object and return its 'addr' value.","command":"jq '.details.addresses[][] | select(.version == 4).addr'","input_text":"{\n \"details\": {\n \"car\": \"bmw\",\n \"addresses\": {\n \"ext-118-21-8-0-29\": [\n {\n \"version\": 4,\n \"addr\": \"89 Psr\"\n },\n {\n \"version\": 6,\n \"addr\": \"56 apT\"\n }\n ]\n }\n }\n}","expected_output":"\"89 Psr\"\n","validation_input":"{\n \"details\": {\n \"car\": \"audi\",\n \"addresses\": {\n \"dynamic-key-123\": [\n {\n \"version\": 6,\n \"addr\": \"::1\"\n },\n {\n \"version\": 4,\n \"addr\": \"192.168.1.1\"\n }\n ]\n }\n }\n}","validation_output":"\"192.168.1.1\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56355822/how-to-use-jq-wildcard","question_title":"How to use jq wildcard","question_owner":"executable","answer_owner":"Jeff Mercado","answer_id":56356012,"question_score":28,"reviewed":true,"paraphrase_of":"so-56355822","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-56555155","request":"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.","command":"jq '.columns.id | if has(\"required\") then .required else false end'","input_text":"{\n \"columns\": {\n \"id\": {\n \"required\": true,\n \"type\": \"integer\"\n },\n \"name\": {\n \"required\": false,\n \"type\": \"string\"\n }\n }\n}","expected_output":"true\n","validation_input":"{\n \"columns\": {\n \"id\": {\n \"type\": \"integer\"\n },\n \"name\": {\n \"required\": true,\n \"type\": \"string\"\n }\n }\n}","validation_output":"false\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq","question_title":"Get or default function in JQ?","question_owner":"Yun Huang","answer_owner":"peak","answer_id":56555442,"question_score":30,"reviewed":true} {"id":"so-56555155-p1","request":"From the \"columns\" definitions in the JSON, get the \"required\" status for the \"id\" column, defaulting to false if the field is absent.","command":"jq '.columns.id | if has(\"required\") then .required else false end'","input_text":"{\n \"columns\": {\n \"id\": {\n \"required\": true,\n \"type\": \"integer\"\n },\n \"name\": {\n \"required\": false,\n \"type\": \"string\"\n }\n }\n}","expected_output":"true\n","validation_input":"{\n \"columns\": {\n \"id\": {\n \"type\": \"integer\"\n },\n \"name\": {\n \"required\": true,\n \"type\": \"string\"\n }\n }\n}","validation_output":"false\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56555155/get-or-default-function-in-jq","question_title":"Get or default function in JQ?","question_owner":"Yun Huang","answer_owner":"peak","answer_id":56555442,"question_score":30,"reviewed":true,"paraphrase_of":"so-56555155","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-56692037","request":"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.","command":"jq -r 'to_entries[] | select(.value | . == null or . == \"\") | if .value == \"\" then .value |= \"\\\"\\(.)\\\"\" else . end | \"\\(.key): \\(.value)\"'","input_text":"{\"name\": \"Color TV\", \"price\": \"1200\", \"available\": \"\"}\n{\"name\": \"DVD player\", \"price\": \"200\", \"color\": null}","expected_output":"available: \"\"\ncolor: null\n","validation_input":"{\"a\": 1, \"b\": \"\", \"c\": null}\n{\"x\": \"hello\", \"y\": 0}","validation_output":"b: \"\"\nc: null\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56692037/filter-empty-and-or-null-values-with-jq","question_title":"Filter empty and/or null values with jq","question_owner":"Fernando César","answer_owner":"peak","answer_id":56694468,"question_score":38,"reviewed":true} {"id":"so-56692037-p1","request":"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.","command":"jq -r 'to_entries[] | select(.value | . == null or . == \"\") | if .value == \"\" then .value |= \"\\\"\\(.)\\\"\" else . end | \"\\(.key): \\(.value)\"'","input_text":"{\"name\": \"Color TV\", \"price\": \"1200\", \"available\": \"\"}\n{\"name\": \"DVD player\", \"price\": \"200\", \"color\": null}","expected_output":"available: \"\"\ncolor: null\n","validation_input":"{\"a\": 1, \"b\": \"\", \"c\": null}\n{\"x\": \"hello\", \"y\": 0}","validation_output":"b: \"\"\nc: null\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56692037/filter-empty-and-or-null-values-with-jq","question_title":"Filter empty and/or null values with jq","question_owner":"Fernando César","answer_owner":"peak","answer_id":56694468,"question_score":38,"reviewed":true,"paraphrase_of":"so-56692037","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-70100534","request":"Extract the first three elements of the 'identifier' array from a JSON object, keeping only the 'system' and 'value' fields for each.","command":"jq '.identifier[:3] | map({system, value})'","input_text":"{\"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\": \"official\", \"system\": \"urn:oid:2.16.724.4.9.10.2\", \"value\": \"0831515\"}]}","expected_output":"[\n {\n \"system\": \"urn:oid:1.3.6.1.4.1.19126.3\",\n \"value\": \"00396185X\"\n },\n {\n \"system\": \"urn:oid:2.16.724.4.9.10.2\",\n \"value\": \"0831515\"\n },\n {\n \"system\": \"urn:oid:2.16.724.4.9.10.2\",\n \"value\": \"0831515\"\n }\n]\n","validation_input":"{\"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\"}]}","validation_output":"[\n {\n \"system\": \"sys1\",\n \"value\": \"val1\"\n },\n {\n \"system\": \"sys2\",\n \"value\": \"val2\"\n },\n {\n \"system\": \"sys3\",\n \"value\": \"val3\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70100534/jq-get-first-n-elements-of-an-array-field","question_title":"jq: get first n elements of an array field","question_owner":"Jordi","answer_owner":"Inian","answer_id":70100645,"question_score":22,"reviewed":true} {"id":"so-70100534-p1","request":"Take the first three items from the 'identifier' array in the JSON object and retain only their 'system' and 'value' fields.","command":"jq '.identifier[:3] | map({system, value})'","input_text":"{\"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\": \"official\", \"system\": \"urn:oid:2.16.724.4.9.10.2\", \"value\": \"0831515\"}]}","expected_output":"[\n {\n \"system\": \"urn:oid:1.3.6.1.4.1.19126.3\",\n \"value\": \"00396185X\"\n },\n {\n \"system\": \"urn:oid:2.16.724.4.9.10.2\",\n \"value\": \"0831515\"\n },\n {\n \"system\": \"urn:oid:2.16.724.4.9.10.2\",\n \"value\": \"0831515\"\n }\n]\n","validation_input":"{\"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\"}]}","validation_output":"[\n {\n \"system\": \"sys1\",\n \"value\": \"val1\"\n },\n {\n \"system\": \"sys2\",\n \"value\": \"val2\"\n },\n {\n \"system\": \"sys3\",\n \"value\": \"val3\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70100534/jq-get-first-n-elements-of-an-array-field","question_title":"jq: get first n elements of an array field","question_owner":"Jordi","answer_owner":"Inian","answer_id":70100645,"question_score":22,"reviewed":true,"paraphrase_of":"so-70100534","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-18796515","request":"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.","command":"jq '.LoadBalancerDescriptions[] | select(.AvailabilityZones[] == \"us-east-1b\") | {CanonicalHostedZoneName, AvailabilityZones}'","input_text":"{\"LoadBalancerDescriptions\": [{\"AvailabilityZones\": [\"us-east-1b\", \"us-east-1c\"], \"CanonicalHostedZoneName\": \"example-1.elb.amazonaws.com\"}, {\"AvailabilityZones\": [\"us-west-2a\"], \"CanonicalHostedZoneName\": \"example-2.elb.amazonaws.com\"}]}","expected_output":"{\n \"CanonicalHostedZoneName\": \"example-1.elb.amazonaws.com\",\n \"AvailabilityZones\": [\n \"us-east-1b\",\n \"us-east-1c\"\n ]\n}\n","validation_input":"{\"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\"}]}","validation_output":"{\n \"CanonicalHostedZoneName\": \"keep-me.elb.amazonaws.com\",\n \"AvailabilityZones\": [\n \"us-east-1b\",\n \"us-east-1c\",\n \"us-east-1d\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18796515/using-jq-to-parse-json-output-of-aws-cli","question_title":"Using jq to parse json output of AWS CLI","question_owner":"cp_clegg","answer_owner":"konsolebox","answer_id":18796928,"question_score":7,"reviewed":true} {"id":"so-18796515-p1","request":"From the LoadBalancerDescriptions array, select entries where the AvailabilityZones list includes \"us-east-1b\", then output the CanonicalHostedZoneName and AvailabilityZones for each selected entry.","command":"jq '.LoadBalancerDescriptions[] | select(.AvailabilityZones[] == \"us-east-1b\") | {CanonicalHostedZoneName, AvailabilityZones}'","input_text":"{\"LoadBalancerDescriptions\": [{\"AvailabilityZones\": [\"us-east-1b\", \"us-east-1c\"], \"CanonicalHostedZoneName\": \"example-1.elb.amazonaws.com\"}, {\"AvailabilityZones\": [\"us-west-2a\"], \"CanonicalHostedZoneName\": \"example-2.elb.amazonaws.com\"}]}","expected_output":"{\n \"CanonicalHostedZoneName\": \"example-1.elb.amazonaws.com\",\n \"AvailabilityZones\": [\n \"us-east-1b\",\n \"us-east-1c\"\n ]\n}\n","validation_input":"{\"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\"}]}","validation_output":"{\n \"CanonicalHostedZoneName\": \"keep-me.elb.amazonaws.com\",\n \"AvailabilityZones\": [\n \"us-east-1b\",\n \"us-east-1c\",\n \"us-east-1d\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18796515/using-jq-to-parse-json-output-of-aws-cli","question_title":"Using jq to parse json output of AWS CLI","question_owner":"cp_clegg","answer_owner":"konsolebox","answer_id":18796928,"question_score":7,"reviewed":true,"paraphrase_of":"so-18796515","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-18837939","request":"Transform an array of arrays by extracting the first element from each subarray.","command":"jq 'map(.[0])'","input_text":"[\n [\n \"sequence\",\n \"int\"\n ],\n [\n \"time\",\n \"string\"\n ]\n]","expected_output":"[\n \"sequence\",\n \"time\"\n]\n","validation_input":"[\n [\n \"id\",\n \"integer\"\n ],\n [\n \"name\",\n \"text\"\n ],\n [\n \"active\",\n \"boolean\"\n ]\n]","validation_output":"[\n \"id\",\n \"name\",\n \"active\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18837939/select-nth-element-from-multidimensional-json-array-with-jq","question_title":"Select nth element from multidimensional JSON array with jq","question_owner":"Dreen","answer_owner":"Psylone","answer_id":18890702,"question_score":10,"reviewed":true} {"id":"so-18837939-p1","request":"Map over an array of arrays to produce a new array consisting of the first element from each inner array.","command":"jq 'map(.[0])'","input_text":"[\n [\n \"sequence\",\n \"int\"\n ],\n [\n \"time\",\n \"string\"\n ]\n]","expected_output":"[\n \"sequence\",\n \"time\"\n]\n","validation_input":"[\n [\n \"id\",\n \"integer\"\n ],\n [\n \"name\",\n \"text\"\n ],\n [\n \"active\",\n \"boolean\"\n ]\n]","validation_output":"[\n \"id\",\n \"name\",\n \"active\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18837939/select-nth-element-from-multidimensional-json-array-with-jq","question_title":"Select nth element from multidimensional JSON array with jq","question_owner":"Dreen","answer_owner":"Psylone","answer_id":18890702,"question_score":10,"reviewed":true,"paraphrase_of":"so-18837939","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-24875419","request":"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.","command":"jq '.students | map({name: .name, age: .age, gpa: .cum_gpa, CSC101: (.semesters | map(.grades) | add | .CSC101)} | select(.CSC101 == \"A\"))'","input_text":"{\n \"students\": [\n {\n \"name\": \"John\",\n \"age\": \"19\",\n \"gender\": \"m\",\n \"from\": \"Tampa, FL\",\n \"cum_gpa\": \"3.83\",\n \"semesters\": [\n {\n \"name\": \"201302\",\n \"gpa\": \"3.67\",\n \"grades\": {\n \"CSC101\": \"A\",\n \"MAT101\": \"A\",\n \"PSY101\": \"B\"\n }\n },\n {\n \"name\": \"201401\",\n \"gpa\": \"4.00\",\n \"grades\": {\n \"CSC201\": \"A\",\n \"MAT201\": \"A\",\n \"HIS101\": \"A\"\n }\n }\n ]\n },\n {\n \"name\": \"Mary\",\n \"age\": \"20\",\n \"gender\": \"f\",\n \"from\": \"Chicago, IL\",\n \"cum_gpa\": \"3.50\",\n \"semesters\": [\n {\n \"name\": \"201302\",\n \"gpa\": \"4.00\",\n \"grades\": {\n \"CSC101\": \"A\",\n \"MAT101\": \"A\",\n \"ECO101\": \"A\"\n }\n },\n {\n \"name\": \"201401\",\n \"gpa\": \"3.00\",\n \"grades\": {\n \"CSC201\": \"B\",\n \"MAT201\": \"B\",\n \"HUM101\": \"B\"\n }\n }\n ]\n },\n {\n \"name\": \"Dan\",\n \"age\": \"20\",\n \"gender\": \"m\",\n \"from\": \"Seattle, WA\",\n \"cum_gpa\": \"3.33\",\n \"semesters\": [\n {\n \"name\": \"201302\",\n \"gpa\": \"3.33\",\n \"grades\": {\n \"CHE101\": \"B\",\n \"MAT101\": \"A\",\n \"PSY101\": \"B\"\n }\n },\n {\n \"name\": \"201401\",\n \"gpa\": \"3.33\",\n \"grades\": {\n \"CHE201\": \"A\",\n \"MAT201\": \"A\",\n \"HUM101\": \"C\"\n }\n }\n ]\n }\n ]\n}","expected_output":"[\n {\n \"name\": \"John\",\n \"age\": \"19\",\n \"gpa\": \"3.83\",\n \"CSC101\": \"A\"\n },\n {\n \"name\": \"Mary\",\n \"age\": \"20\",\n \"gpa\": \"3.50\",\n \"CSC101\": \"A\"\n }\n]\n","validation_input":"{\n \"students\": [\n {\n \"name\": \"Alice\",\n \"age\": \"21\",\n \"gender\": \"f\",\n \"from\": \"Boston, MA\",\n \"cum_gpa\": \"3.90\",\n \"semesters\": [\n {\n \"name\": \"202301\",\n \"gpa\": \"3.90\",\n \"grades\": {\n \"CSC101\": \"A\",\n \"ENG101\": \"A\"\n }\n }\n ]\n },\n {\n \"name\": \"Bob\",\n \"age\": \"22\",\n \"gender\": \"m\",\n \"from\": \"Austin, TX\",\n \"cum_gpa\": \"3.20\",\n \"semesters\": [\n {\n \"name\": \"202301\",\n \"gpa\": \"3.20\",\n \"grades\": {\n \"CSC101\": \"B\",\n \"ENG101\": \"A\"\n }\n }\n ]\n }\n ]\n}","validation_output":"[\n {\n \"name\": \"Alice\",\n \"age\": \"21\",\n \"gpa\": \"3.90\",\n \"CSC101\": \"A\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24875419/complex-jq-filter","question_title":"Complex jq Filter","question_owner":"AJ.","answer_owner":"Jeff Mercado","answer_id":24875844,"question_score":6,"reviewed":true} {"id":"so-28103489","request":"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.","command":"jq '.[0] as $keys | .[1] as $values | reduce range(0; $keys|length) as $i ( {}; . + { ($keys[$i]): $values[$i] })'","input_text":"[[\"key1\", \"key2\"], [\"val1\", \"val2\"]]","expected_output":"{\n \"key1\": \"val1\",\n \"key2\": \"val2\"\n}\n","validation_input":"[[\"name\", \"age\", \"city\"], [\"Alice\", 30, \"NYC\"]]","validation_output":"{\n \"name\": \"Alice\",\n \"age\": 30,\n \"city\": \"NYC\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28103489/create-object-from-array-of-keys-and-values","question_title":"Create object from array of keys and values","question_owner":"Abdullah Jibaly","answer_owner":"Abdullah Jibaly","answer_id":28117842,"question_score":9,"reviewed":true} {"id":"so-28103489-p1","request":"Create a JSON object by pairing keys from the first subarray with values from the second subarray of the input two-element array.","command":"jq '.[0] as $keys | .[1] as $values | reduce range(0; $keys|length) as $i ( {}; . + { ($keys[$i]): $values[$i] })'","input_text":"[[\"key1\", \"key2\"], [\"val1\", \"val2\"]]","expected_output":"{\n \"key1\": \"val1\",\n \"key2\": \"val2\"\n}\n","validation_input":"[[\"name\", \"age\", \"city\"], [\"Alice\", 30, \"NYC\"]]","validation_output":"{\n \"name\": \"Alice\",\n \"age\": 30,\n \"city\": \"NYC\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28103489/create-object-from-array-of-keys-and-values","question_title":"Create object from array of keys and values","question_owner":"Abdullah Jibaly","answer_owner":"Abdullah Jibaly","answer_id":28117842,"question_score":9,"reviewed":true,"paraphrase_of":"so-28103489","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-28458046","request":"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.","command":"jq -c '[.[] | select(.Selected != null) | {\"Head Of House Name\", \"Head Of House Phone\", \"Family Phone\"}]'","input_text":"[\n {\n \"Selected\": null,\n \"Family Name\": \"Jones\",\n \"Head Of House Name\": \"Jones, Adam\",\n \"Head Of House Phone\": \"111\",\n \"Family Phone\": \"222\"\n },\n {\n \"Selected\": \"x\",\n \"Family Name\": \"Xiong\",\n \"Head Of House Name\": \"Xiong, Arlene\",\n \"Head Of House Phone\": \"333\",\n \"Family Phone\": null\n }\n]","expected_output":"[{\"Head Of House Name\":\"Xiong, Arlene\",\"Head Of House Phone\":\"333\",\"Family Phone\":null}]\n","validation_input":"[\n {\n \"Selected\": \"x\",\n \"Family Name\": \"Blair\",\n \"Head Of House Name\": \"Blair, Toby\",\n \"Head Of House Phone\": \"444\",\n \"Family Phone\": \"555\"\n },\n {\n \"Selected\": null,\n \"Family Name\": \"Smith\",\n \"Head Of House Name\": \"Smith, John\",\n \"Head Of House Phone\": \"666\",\n \"Family Phone\": \"777\"\n }\n]","validation_output":"[{\"Head Of House Name\":\"Blair, Toby\",\"Head Of House Phone\":\"444\",\"Family Phone\":\"555\"}]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28458046/how-can-i-filter-an-array-of-json-objects-using-jq","question_title":"How can I filter an array of json objects using jq?","question_owner":"David Vezzani","answer_owner":"Jeff Mercado","answer_id":28461226,"question_score":10,"reviewed":true} {"id":"so-28458046-p1","request":"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.","command":"jq -c '[.[] | select(.Selected != null) | {\"Head Of House Name\", \"Head Of House Phone\", \"Family Phone\"}]'","input_text":"[\n {\n \"Selected\": null,\n \"Family Name\": \"Jones\",\n \"Head Of House Name\": \"Jones, Adam\",\n \"Head Of House Phone\": \"111\",\n \"Family Phone\": \"222\"\n },\n {\n \"Selected\": \"x\",\n \"Family Name\": \"Xiong\",\n \"Head Of House Name\": \"Xiong, Arlene\",\n \"Head Of House Phone\": \"333\",\n \"Family Phone\": null\n }\n]","expected_output":"[{\"Head Of House Name\":\"Xiong, Arlene\",\"Head Of House Phone\":\"333\",\"Family Phone\":null}]\n","validation_input":"[\n {\n \"Selected\": \"x\",\n \"Family Name\": \"Blair\",\n \"Head Of House Name\": \"Blair, Toby\",\n \"Head Of House Phone\": \"444\",\n \"Family Phone\": \"555\"\n },\n {\n \"Selected\": null,\n \"Family Name\": \"Smith\",\n \"Head Of House Name\": \"Smith, John\",\n \"Head Of House Phone\": \"666\",\n \"Family Phone\": \"777\"\n }\n]","validation_output":"[{\"Head Of House Name\":\"Blair, Toby\",\"Head Of House Phone\":\"444\",\"Family Phone\":\"555\"}]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28458046/how-can-i-filter-an-array-of-json-objects-using-jq","question_title":"How can I filter an array of json objects using jq?","question_owner":"David Vezzani","answer_owner":"Jeff Mercado","answer_id":28461226,"question_score":10,"reviewed":true,"paraphrase_of":"so-28458046","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-29259249","request":"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.","command":"jq 'map(.properties |= with_entries(select(.key == (\"NAME\", \"NAME_LONG\"))))'","input_text":"[{\"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\": \"-99\", \"TYPE\": \"Dependency\", \"NAME_LONG\": \"Anguilla\"}}]","expected_output":"[\n {\n \"geometry\": {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -69.9,\n 12.5\n ]\n ]\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Aruba\",\n \"NAME_LONG\": \"Aruba\"\n }\n },\n {\n \"geometry\": {\n \"type\": \"MultiPolygon\",\n \"coordinates\": [\n [\n [\n -63,\n 18.2\n ]\n ]\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Anguilla\",\n \"NAME_LONG\": \"Anguilla\"\n }\n }\n]\n","validation_input":"[{\"geometry\": {\"type\": \"Point\", \"coordinates\": [0, 0]}, \"type\": \"Feature\", \"properties\": {\"NAME\": \"Test\", \"CODE\": \"T1\", \"POP\": 100, \"NAME_LONG\": \"Test Island\"}}]","validation_output":"[\n {\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 0,\n 0\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Test\",\n \"NAME_LONG\": \"Test Island\"\n }\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29259249/extracting-selected-properties-from-a-nested-json-object-with-jq","question_title":"Extracting selected properties from a nested JSON object with jq","question_owner":"Rob Cowie","answer_owner":"Jeff Mercado","answer_id":29259478,"question_score":9,"reviewed":true} {"id":"so-29259249-p1","request":"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'.","command":"jq 'map(.properties |= with_entries(select(.key == (\"NAME\", \"NAME_LONG\"))))'","input_text":"[{\"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\": \"-99\", \"TYPE\": \"Dependency\", \"NAME_LONG\": \"Anguilla\"}}]","expected_output":"[\n {\n \"geometry\": {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -69.9,\n 12.5\n ]\n ]\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Aruba\",\n \"NAME_LONG\": \"Aruba\"\n }\n },\n {\n \"geometry\": {\n \"type\": \"MultiPolygon\",\n \"coordinates\": [\n [\n [\n -63,\n 18.2\n ]\n ]\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Anguilla\",\n \"NAME_LONG\": \"Anguilla\"\n }\n }\n]\n","validation_input":"[{\"geometry\": {\"type\": \"Point\", \"coordinates\": [0, 0]}, \"type\": \"Feature\", \"properties\": {\"NAME\": \"Test\", \"CODE\": \"T1\", \"POP\": 100, \"NAME_LONG\": \"Test Island\"}}]","validation_output":"[\n {\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 0,\n 0\n ]\n },\n \"type\": \"Feature\",\n \"properties\": {\n \"NAME\": \"Test\",\n \"NAME_LONG\": \"Test Island\"\n }\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29259249/extracting-selected-properties-from-a-nested-json-object-with-jq","question_title":"Extracting selected properties from a nested JSON object with jq","question_owner":"Rob Cowie","answer_owner":"Jeff Mercado","answer_id":29259478,"question_score":9,"reviewed":true,"paraphrase_of":"so-29259249","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-30768196","request":"Extract OptionGroupName, InstanceIdentifier, and Version from each collection item and output them as tab-separated values.","command":"jq -r '.Collections[] | [.OptionGroups[].OptionGroupName, .InstanceIdentifier, .Version] | join(\"\\t\")'","input_text":"{\"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\"}]}\n{\"Collections\": [{\"OptionGroups\": [{\"OptionGroupName\": \"Prod1\", \"Status\": \"active\"}], \"Version\": \"5.0.0\", \"InstanceIdentifier\": \"Main1\"}]}","expected_output":"Test1\tDev1\t3.4.25\nTest2\tDev2\t3.4.22\nProd1\tMain1\t5.0.0\n","validation_input":"{\"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\"}]}","validation_output":"Test1\tDev1\t3.4.25\nTest2\tDev2\t3.4.22\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30768196/multiple-filters-using-jq","question_title":"Multiple filters using JQ","question_owner":"jago","answer_owner":"Jeff Mercado","answer_id":30769322,"question_score":7,"reviewed":true} {"id":"so-30768196-p1","request":"Retrieve OptionGroupName, InstanceIdentifier, and Version from each item in the collection and format the output as tab-separated values.","command":"jq -r '.Collections[] | [.OptionGroups[].OptionGroupName, .InstanceIdentifier, .Version] | join(\"\\t\")'","input_text":"{\"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\"}]}\n{\"Collections\": [{\"OptionGroups\": [{\"OptionGroupName\": \"Prod1\", \"Status\": \"active\"}], \"Version\": \"5.0.0\", \"InstanceIdentifier\": \"Main1\"}]}","expected_output":"Test1\tDev1\t3.4.25\nTest2\tDev2\t3.4.22\nProd1\tMain1\t5.0.0\n","validation_input":"{\"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\"}]}","validation_output":"Test1\tDev1\t3.4.25\nTest2\tDev2\t3.4.22\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/30768196/multiple-filters-using-jq","question_title":"Multiple filters using JQ","question_owner":"jago","answer_owner":"Jeff Mercado","answer_id":30769322,"question_score":7,"reviewed":true,"paraphrase_of":"so-30768196","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-31161831","request":"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.","command":"jq '{\"v\":(.version+1)}'","input_text":"{\"version\":1}","expected_output":"{\n \"v\": 2\n}\n","validation_input":"{\"version\":5}","validation_output":"{\n \"v\": 6\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31161831/how-to-increment-a-number-when-transforming-json","question_title":"How to increment a number when transforming json","question_owner":"neurolabs","answer_owner":"Rambo Ramon","answer_id":31162086,"question_score":5,"reviewed":true} {"id":"so-31161831-p1","request":"Take a JSON object with a numeric 'version' property and return a new object where the field 'v' equals the original version plus one.","command":"jq '{\"v\":(.version+1)}'","input_text":"{\"version\":1}","expected_output":"{\n \"v\": 2\n}\n","validation_input":"{\"version\":5}","validation_output":"{\n \"v\": 6\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31161831/how-to-increment-a-number-when-transforming-json","question_title":"How to increment a number when transforming json","question_owner":"neurolabs","answer_owner":"Rambo Ramon","answer_id":31162086,"question_score":5,"reviewed":true,"paraphrase_of":"so-31161831","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-32275538","request":"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).","command":"jq -r '[.ClassIdentifier, (.StateMode // \"null\"), (.StateGroups | map(select(.Status==\"active\").StateGroupName) | sort | join(\"|\") | if .==\"\" then \"null\" else . end)] | @csv'","input_text":"{\"ClassIdentifier\": \"consumer-leads\", \"StateMode\": \"txt-2300\", \"StateGroups\": []}\n{\"ClassIdentifier\": \"main\", \"StateMode\": null, \"StateGroups\": [{\"Status\": \"active\", \"StateGroupName\": \"default\"}, {\"Status\": \"active\", \"StateGroupName\": \"brown-space\"}, {\"Status\": \"active\", \"StateGroupName\": \"txt-hosts\"}]}","expected_output":"\"consumer-leads\",\"txt-2300\",\"null\"\n\"main\",\"null\",\"brown-space|default|txt-hosts\"\n","validation_input":"{\"ClassIdentifier\": \"paid-media\", \"StateMode\": \"txt-2300\", \"StateGroups\": []}\n{\"ClassIdentifier\": \"reports\", \"StateMode\": null, \"StateGroups\": [{\"Status\": \"active\", \"StateGroupName\": \"txt-hosts\"}, {\"Status\": \"active\", \"StateGroupName\": \"grey-space\"}, {\"Status\": \"active\", \"StateGroupName\": \"default\"}]}","validation_output":"\"paid-media\",\"txt-2300\",\"null\"\n\"reports\",\"null\",\"default|grey-space|txt-hosts\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32275538/make-jq-transform-an-array-of-objects-to-a-string","question_title":"Make JQ transform an array of objects to a string","question_owner":"jago","answer_owner":"Jeff Mercado","answer_id":32276111,"question_score":9,"reviewed":true} {"id":"so-32275538-p1","request":"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).","command":"jq -r '[.ClassIdentifier, (.StateMode // \"null\"), (.StateGroups | map(select(.Status==\"active\").StateGroupName) | sort | join(\"|\") | if .==\"\" then \"null\" else . end)] | @csv'","input_text":"{\"ClassIdentifier\": \"consumer-leads\", \"StateMode\": \"txt-2300\", \"StateGroups\": []}\n{\"ClassIdentifier\": \"main\", \"StateMode\": null, \"StateGroups\": [{\"Status\": \"active\", \"StateGroupName\": \"default\"}, {\"Status\": \"active\", \"StateGroupName\": \"brown-space\"}, {\"Status\": \"active\", \"StateGroupName\": \"txt-hosts\"}]}","expected_output":"\"consumer-leads\",\"txt-2300\",\"null\"\n\"main\",\"null\",\"brown-space|default|txt-hosts\"\n","validation_input":"{\"ClassIdentifier\": \"paid-media\", \"StateMode\": \"txt-2300\", \"StateGroups\": []}\n{\"ClassIdentifier\": \"reports\", \"StateMode\": null, \"StateGroups\": [{\"Status\": \"active\", \"StateGroupName\": \"txt-hosts\"}, {\"Status\": \"active\", \"StateGroupName\": \"grey-space\"}, {\"Status\": \"active\", \"StateGroupName\": \"default\"}]}","validation_output":"\"paid-media\",\"txt-2300\",\"null\"\n\"reports\",\"null\",\"default|grey-space|txt-hosts\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32275538/make-jq-transform-an-array-of-objects-to-a-string","question_title":"Make JQ transform an array of objects to a string","question_owner":"jago","answer_owner":"Jeff Mercado","answer_id":32276111,"question_score":9,"reviewed":true,"paraphrase_of":"so-32275538","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-32357240","request":"Transform an array of objects with 'name' and 'keys' fields into a single object where each key from the 'keys' arrays maps to an array of names that contained that key.","command":"jq 'map({ name, key: .keys[] }) | group_by(.key) | map({ key: .[0].key, value: map(.name) }) | from_entries'","input_text":"[\n {\n \"name\": \"A\",\n \"keys\": [\"k1\", \"k2\", \"k3\"]\n },\n {\n \"name\": \"B\",\n \"keys\": [\"k2\", \"k3\", \"k4\"]\n }\n]","expected_output":"{\n \"k1\": [\n \"A\"\n ],\n \"k2\": [\n \"A\",\n \"B\"\n ],\n \"k3\": [\n \"A\",\n \"B\"\n ],\n \"k4\": [\n \"B\"\n ]\n}\n","validation_input":"[\n {\n \"name\": \"X\",\n \"keys\": [\"p1\", \"p2\"]\n },\n {\n \"name\": \"Y\",\n \"keys\": [\"p2\", \"p3\"]\n },\n {\n \"name\": \"Z\",\n \"keys\": [\"p1\", \"p3\"]\n }\n]","validation_output":"{\n \"p1\": [\n \"X\",\n \"Z\"\n ],\n \"p2\": [\n \"X\",\n \"Y\"\n ],\n \"p3\": [\n \"Y\",\n \"Z\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32357240/transposing-objects-in-jq","question_title":""Transposing" objects in jq","question_owner":"cmbuckley","answer_owner":"Jeff Mercado","answer_id":32359453,"question_score":7,"reviewed":true} {"id":"so-32357240-p1","request":"Aggregate an array of objects with 'name' and 'keys' fields into a single map where each unique key points to a list of names associated with it.","command":"jq 'map({ name, key: .keys[] }) | group_by(.key) | map({ key: .[0].key, value: map(.name) }) | from_entries'","input_text":"[\n {\n \"name\": \"A\",\n \"keys\": [\"k1\", \"k2\", \"k3\"]\n },\n {\n \"name\": \"B\",\n \"keys\": [\"k2\", \"k3\", \"k4\"]\n }\n]","expected_output":"{\n \"k1\": [\n \"A\"\n ],\n \"k2\": [\n \"A\",\n \"B\"\n ],\n \"k3\": [\n \"A\",\n \"B\"\n ],\n \"k4\": [\n \"B\"\n ]\n}\n","validation_input":"[\n {\n \"name\": \"X\",\n \"keys\": [\"p1\", \"p2\"]\n },\n {\n \"name\": \"Y\",\n \"keys\": [\"p2\", \"p3\"]\n },\n {\n \"name\": \"Z\",\n \"keys\": [\"p1\", \"p3\"]\n }\n]","validation_output":"{\n \"p1\": [\n \"X\",\n \"Z\"\n ],\n \"p2\": [\n \"X\",\n \"Y\"\n ],\n \"p3\": [\n \"Y\",\n \"Z\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32357240/transposing-objects-in-jq","question_title":""Transposing" objects in jq","question_owner":"cmbuckley","answer_owner":"Jeff Mercado","answer_id":32359453,"question_score":7,"reviewed":true,"paraphrase_of":"so-32357240","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-32629301","request":"Parse the JSON string contained in the 'categoriesListArr' field of the input object and replace the string with the resulting JSON object.","command":"jq '.categoriesListArr |= fromjson'","input_text":"{\"logo\":{\"name\":\"logo.png\"},\"categoriesListArr\":\"{\\\"Women\\\":[\\\"Shoes\\\"],\\\"Men\\\":[\\\"Hats\\\"]}\"}","expected_output":"{\n \"logo\": {\n \"name\": \"logo.png\"\n },\n \"categoriesListArr\": {\n \"Women\": [\n \"Shoes\"\n ],\n \"Men\": [\n \"Hats\"\n ]\n }\n}\n","validation_input":"{\"logo\":{\"name\":\"logo.png\"},\"categoriesListArr\":\"{\\\"A\\\":[1],\\\"B\\\":[2]}\"}","validation_output":"{\n \"logo\": {\n \"name\": \"logo.png\"\n },\n \"categoriesListArr\": {\n \"A\": [\n 1\n ],\n \"B\": [\n 2\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32629301/get-json-object-from-stringify-object-using-jq-filter-in-shell-script","question_title":"get json object from stringify object using jq filter in shell script","question_owner":"Ranjit Singh","answer_owner":"peak","answer_id":32633865,"question_score":9,"reviewed":true} {"id":"so-32629301-p1","request":"Parse the JSON string found in the 'categoriesListArr' field of the input object and replace that string with the parsed JSON structure.","command":"jq '.categoriesListArr |= fromjson'","input_text":"{\"logo\":{\"name\":\"logo.png\"},\"categoriesListArr\":\"{\\\"Women\\\":[\\\"Shoes\\\"],\\\"Men\\\":[\\\"Hats\\\"]}\"}","expected_output":"{\n \"logo\": {\n \"name\": \"logo.png\"\n },\n \"categoriesListArr\": {\n \"Women\": [\n \"Shoes\"\n ],\n \"Men\": [\n \"Hats\"\n ]\n }\n}\n","validation_input":"{\"logo\":{\"name\":\"logo.png\"},\"categoriesListArr\":\"{\\\"A\\\":[1],\\\"B\\\":[2]}\"}","validation_output":"{\n \"logo\": {\n \"name\": \"logo.png\"\n },\n \"categoriesListArr\": {\n \"A\": [\n 1\n ],\n \"B\": [\n 2\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32629301/get-json-object-from-stringify-object-using-jq-filter-in-shell-script","question_title":"get json object from stringify object using jq filter in shell script","question_owner":"Ranjit Singh","answer_owner":"peak","answer_id":32633865,"question_score":9,"reviewed":true,"paraphrase_of":"so-32629301","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-32750745","request":"Convert a JSON array into newline-delimited JSON objects, one per line.","command":"jq -c '.[]'","input_text":"[[1,2], 3, {\"4\":5}]\n","expected_output":"[1,2]\n3\n{\"4\":5}\n","validation_input":"[{\"a\":1}, {\"b\":2}]\n","validation_output":"{\"a\":1}\n{\"b\":2}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32750745/converting-comma-delimited-json-to-a-newline-delimited-node","question_title":"Converting comma delimited JSON to a newline delimited node","question_owner":"kisonay","answer_owner":"peak","answer_id":32752044,"question_score":5,"reviewed":true} {"id":"so-32750745-p1","request":"Serialize a JSON array into a sequence of newline-separated JSON objects, with one object per line.","command":"jq -c '.[]'","input_text":"[[1,2], 3, {\"4\":5}]\n","expected_output":"[1,2]\n3\n{\"4\":5}\n","validation_input":"[{\"a\":1}, {\"b\":2}]\n","validation_output":"{\"a\":1}\n{\"b\":2}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/32750745/converting-comma-delimited-json-to-a-newline-delimited-node","question_title":"Converting comma delimited JSON to a newline delimited node","question_owner":"kisonay","answer_owner":"peak","answer_id":32752044,"question_score":5,"reviewed":true,"paraphrase_of":"so-32750745","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-33572755","request":"For each input object, add or update the 'partner_attributions' field to be 'yes' if the original array has elements, otherwise 'no'.","command":"jq '.partner_attributions = (if (.partner_attributions | length) > 0 then \"yes\" else \"no\" end)'","input_text":"{\"_key\": \"USCA3DC_8f4521822c099c3e\", \"partner_attributions\": [\"This business is a Yelp advertiser.\"], \"review_count\": \"24\"}\n{\"_key\": \"USCA3DC_other\", \"partner_attributions\": [], \"review_count\": \"10\"}","expected_output":"{\n \"_key\": \"USCA3DC_8f4521822c099c3e\",\n \"partner_attributions\": \"yes\",\n \"review_count\": \"24\"\n}\n{\n \"_key\": \"USCA3DC_other\",\n \"partner_attributions\": \"no\",\n \"review_count\": \"10\"\n}\n","validation_input":"{\"partner_attributions\": [\"a\", \"b\"]}\n{\"partner_attributions\": null}\n{\"partner_attributions\": []}","validation_output":"{\n \"partner_attributions\": \"yes\"\n}\n{\n \"partner_attributions\": \"no\"\n}\n{\n \"partner_attributions\": \"no\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33572755/jq-if-then-else","question_title":"JQ If then Else","question_owner":"Tom","answer_owner":"jwodder","answer_id":33572853,"question_score":6,"reviewed":true} {"id":"so-33572755-p1","request":"Set the 'partner_attributions' field to 'yes' if the source array is non-empty, otherwise set it to 'no'.","command":"jq '.partner_attributions = (if (.partner_attributions | length) > 0 then \"yes\" else \"no\" end)'","input_text":"{\"_key\": \"USCA3DC_8f4521822c099c3e\", \"partner_attributions\": [\"This business is a Yelp advertiser.\"], \"review_count\": \"24\"}\n{\"_key\": \"USCA3DC_other\", \"partner_attributions\": [], \"review_count\": \"10\"}","expected_output":"{\n \"_key\": \"USCA3DC_8f4521822c099c3e\",\n \"partner_attributions\": \"yes\",\n \"review_count\": \"24\"\n}\n{\n \"_key\": \"USCA3DC_other\",\n \"partner_attributions\": \"no\",\n \"review_count\": \"10\"\n}\n","validation_input":"{\"partner_attributions\": [\"a\", \"b\"]}\n{\"partner_attributions\": null}\n{\"partner_attributions\": []}","validation_output":"{\n \"partner_attributions\": \"yes\"\n}\n{\n \"partner_attributions\": \"no\"\n}\n{\n \"partner_attributions\": \"no\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33572755/jq-if-then-else","question_title":"JQ If then Else","question_owner":"Tom","answer_owner":"jwodder","answer_id":33572853,"question_score":6,"reviewed":true,"paraphrase_of":"so-33572755","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-33700997","request":"Transform the input object into an array of objects where each object has a single key derived from the original keys and a value from the nested CPU PercentUsed field.","command":"jq 'to_entries | map({ (.key) : .value.CPU.PercentUsed })'","input_text":"{\"rpi-b827eb2d7d23\": {\"CPU\": {\"PercentUsed\": 10.333333333333334}}, \"rpi-b827eb8d7c8d\": {\"CPU\": {\"PercentUsed\": 60}}}","expected_output":"[\n {\n \"rpi-b827eb2d7d23\": 10.333333333333334\n },\n {\n \"rpi-b827eb8d7c8d\": 60\n }\n]\n","validation_input":"{\"host1\": {\"CPU\": {\"PercentUsed\": 50.5}}, \"host2\": {\"CPU\": {\"PercentUsed\": 20.0}}, \"host3\": {\"CPU\": {\"PercentUsed\": 99.9}}}","validation_output":"[\n {\n \"host1\": 50.5\n },\n {\n \"host2\": 20\n },\n {\n \"host3\": 99.9\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33700997/parentheses-in-jq-for-key","question_title":"Parentheses in JQ for .key","question_owner":"Kyle Brandt","answer_owner":"Jeff Mercado","answer_id":33701068,"question_score":7,"reviewed":true} {"id":"so-33700997-p1","request":"Flatten the input object into an array of single-key objects, mapping each original key to its nested CPU PercentUsed value.","command":"jq 'to_entries | map({ (.key) : .value.CPU.PercentUsed })'","input_text":"{\"rpi-b827eb2d7d23\": {\"CPU\": {\"PercentUsed\": 10.333333333333334}}, \"rpi-b827eb8d7c8d\": {\"CPU\": {\"PercentUsed\": 60}}}","expected_output":"[\n {\n \"rpi-b827eb2d7d23\": 10.333333333333334\n },\n {\n \"rpi-b827eb8d7c8d\": 60\n }\n]\n","validation_input":"{\"host1\": {\"CPU\": {\"PercentUsed\": 50.5}}, \"host2\": {\"CPU\": {\"PercentUsed\": 20.0}}, \"host3\": {\"CPU\": {\"PercentUsed\": 99.9}}}","validation_output":"[\n {\n \"host1\": 50.5\n },\n {\n \"host2\": 20\n },\n {\n \"host3\": 99.9\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33700997/parentheses-in-jq-for-key","question_title":"Parentheses in JQ for .key","question_owner":"Kyle Brandt","answer_owner":"Jeff Mercado","answer_id":33701068,"question_score":7,"reviewed":true,"paraphrase_of":"so-33700997","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-34510742","request":"Add an incremental id field to each object in the input array. The id should be formatted as \"xx_\" followed by the 1-based index of the element.","command":"jq '[to_entries[] | .value + {\"id\": (\"xx_\" + ((.key + 1) | tostring))}]'","input_text":"[\n{\"data\":\"a\"},\n{\"data\":\"b\"},\n{\"data\":\"c\"}\n]","expected_output":"[\n {\n \"data\": \"a\",\n \"id\": \"xx_1\"\n },\n {\n \"data\": \"b\",\n \"id\": \"xx_2\"\n },\n {\n \"data\": \"c\",\n \"id\": \"xx_3\"\n }\n]\n","validation_input":"[\n{\"name\":\"x\"},\n{\"name\":\"y\"}\n]","validation_output":"[\n {\n \"name\": \"x\",\n \"id\": \"xx_1\"\n },\n {\n \"name\": \"y\",\n \"id\": \"xx_2\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34510742/how-do-i-create-an-incremental-index-with-jq","question_title":"How do I create an incremental index with jq","question_owner":"UVRadiation","answer_owner":"peak","answer_id":34513774,"question_score":8,"reviewed":true} {"id":"so-34510742-p1","request":"Append an incremental 'id' to every item in the array, formatted as \"xx_\" followed by the 1-based index.","command":"jq '[to_entries[] | .value + {\"id\": (\"xx_\" + ((.key + 1) | tostring))}]'","input_text":"[\n{\"data\":\"a\"},\n{\"data\":\"b\"},\n{\"data\":\"c\"}\n]","expected_output":"[\n {\n \"data\": \"a\",\n \"id\": \"xx_1\"\n },\n {\n \"data\": \"b\",\n \"id\": \"xx_2\"\n },\n {\n \"data\": \"c\",\n \"id\": \"xx_3\"\n }\n]\n","validation_input":"[\n{\"name\":\"x\"},\n{\"name\":\"y\"}\n]","validation_output":"[\n {\n \"name\": \"x\",\n \"id\": \"xx_1\"\n },\n {\n \"name\": \"y\",\n \"id\": \"xx_2\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34510742/how-do-i-create-an-incremental-index-with-jq","question_title":"How do I create an incremental index with jq","question_owner":"UVRadiation","answer_owner":"peak","answer_id":34513774,"question_score":8,"reviewed":true,"paraphrase_of":"so-34510742","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-35199809","request":"From a stream of JSON objects, select only those objects that do not have the key 'target'.","command":"jq 'select(has(\"target\") | not)'","input_text":"{\"name\":\"JSON\",\"good\":true,\"target\":\"yes\"}\n{\"name\":\"XML\",\"good\":false}","expected_output":"{\n \"name\": \"XML\",\n \"good\": false\n}\n","validation_input":"{\"id\": 1, \"active\": true}\n{\"id\": 2, \"active\": false, \"target\": \"main\"}","validation_output":"{\n \"id\": 1,\n \"active\": true\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35199809/jq-exclude-object-with-specified-key","question_title":"jq: exclude object with specified key","question_owner":"LPby","answer_owner":"user3899165","answer_id":35202218,"question_score":6,"reviewed":true} {"id":"so-35199809-p1","request":"Filter the JSON stream to include only objects that lack the 'target' key.","command":"jq 'select(has(\"target\") | not)'","input_text":"{\"name\":\"JSON\",\"good\":true,\"target\":\"yes\"}\n{\"name\":\"XML\",\"good\":false}","expected_output":"{\n \"name\": \"XML\",\n \"good\": false\n}\n","validation_input":"{\"id\": 1, \"active\": true}\n{\"id\": 2, \"active\": false, \"target\": \"main\"}","validation_output":"{\n \"id\": 1,\n \"active\": true\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35199809/jq-exclude-object-with-specified-key","question_title":"jq: exclude object with specified key","question_owner":"LPby","answer_owner":"user3899165","answer_id":35202218,"question_score":6,"reviewed":true,"paraphrase_of":"so-35199809","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-37559582","request":"Given a JSON object containing a DistributionList with Items, where each Item has an Id and Origins containing Items with their own Ids, find the parent Item's Id for a specific child Origin Id. Specifically, return the Id of the parent object that contains an Origin with Id \"abc\".","command":"jq '.. | objects | select(.Origins.Items[]? | .Id == \"abc\") | .Id'","input_text":"{\"DistributionList\":{\"Items\":[{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"parent123\"},{\"Origins\":{\"Items\":[{\"Id\":\"def\"}],\"Quantity\":1},\"Id\":\"parent345\"}]}}","expected_output":"\"parent123\"\n","validation_input":"{\"DistributionList\":{\"Items\":[{\"Origins\":{\"Items\":[{\"Id\":\"xyz\"}],\"Quantity\":1},\"Id\":\"p1\"},{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"p2\"},{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"p3\"}]}}","validation_output":"\"p2\"\n\"p3\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37559582/return-parent-node-with-jq-while-querying-one-of-its-children","question_title":"Return parent node with jq while querying one of its children","question_owner":"Marty","answer_owner":"peak","answer_id":37560129,"question_score":5,"reviewed":true} {"id":"so-37559582-p1","request":"Identify and return the parent Item Id that contains an Origin with Id \"abc\" within the DistributionList structure.","command":"jq '.. | objects | select(.Origins.Items[]? | .Id == \"abc\") | .Id'","input_text":"{\"DistributionList\":{\"Items\":[{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"parent123\"},{\"Origins\":{\"Items\":[{\"Id\":\"def\"}],\"Quantity\":1},\"Id\":\"parent345\"}]}}","expected_output":"\"parent123\"\n","validation_input":"{\"DistributionList\":{\"Items\":[{\"Origins\":{\"Items\":[{\"Id\":\"xyz\"}],\"Quantity\":1},\"Id\":\"p1\"},{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"p2\"},{\"Origins\":{\"Items\":[{\"Id\":\"abc\"}],\"Quantity\":1},\"Id\":\"p3\"}]}}","validation_output":"\"p2\"\n\"p3\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37559582/return-parent-node-with-jq-while-querying-one-of-its-children","question_title":"Return parent node with jq while querying one of its children","question_owner":"Marty","answer_owner":"peak","answer_id":37560129,"question_score":5,"reviewed":true,"paraphrase_of":"so-37559582","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-38335869","request":"For each object in the DBInstances array, ensure the 'bar' key exists; if it is missing, set its value to 'NA', otherwise keep the original value.","command":"jq '.DBInstances[] |= if has(\"bar\") then . else .bar = \"NA\" end'","input_text":"{\"DBInstances\": [{\"Identifier\": 101, \"foo\": \"some_value\", \"bar\": 60, \"Model\": \"A\"}, {\"Identifier\": 102, \"foo\": \"some_value\", \"Model\": \"B\"}]}","expected_output":"{\n \"DBInstances\": [\n {\n \"Identifier\": 101,\n \"foo\": \"some_value\",\n \"bar\": 60,\n \"Model\": \"A\"\n },\n {\n \"Identifier\": 102,\n \"foo\": \"some_value\",\n \"Model\": \"B\",\n \"bar\": \"NA\"\n }\n ]\n}\n","validation_input":"{\"DBInstances\": [{\"Identifier\": 103, \"bar\": \"existing\"}, {\"Identifier\": 104}]}","validation_output":"{\n \"DBInstances\": [\n {\n \"Identifier\": 103,\n \"bar\": \"existing\"\n },\n {\n \"Identifier\": 104,\n \"bar\": \"NA\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38335869/acting-on-the-existence-or-non-existence-of-a-key-using-jq","question_title":"Acting on the existence or non-existence of a key using JQ","question_owner":"jago","answer_owner":"peak","answer_id":38337572,"question_score":6,"reviewed":true} {"id":"so-38335869-p1","request":"Ensure every object in the DBInstances array has a 'bar' key; assign 'NA' if missing, otherwise retain the existing value.","command":"jq '.DBInstances[] |= if has(\"bar\") then . else .bar = \"NA\" end'","input_text":"{\"DBInstances\": [{\"Identifier\": 101, \"foo\": \"some_value\", \"bar\": 60, \"Model\": \"A\"}, {\"Identifier\": 102, \"foo\": \"some_value\", \"Model\": \"B\"}]}","expected_output":"{\n \"DBInstances\": [\n {\n \"Identifier\": 101,\n \"foo\": \"some_value\",\n \"bar\": 60,\n \"Model\": \"A\"\n },\n {\n \"Identifier\": 102,\n \"foo\": \"some_value\",\n \"Model\": \"B\",\n \"bar\": \"NA\"\n }\n ]\n}\n","validation_input":"{\"DBInstances\": [{\"Identifier\": 103, \"bar\": \"existing\"}, {\"Identifier\": 104}]}","validation_output":"{\n \"DBInstances\": [\n {\n \"Identifier\": 103,\n \"bar\": \"existing\"\n },\n {\n \"Identifier\": 104,\n \"bar\": \"NA\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38335869/acting-on-the-existence-or-non-existence-of-a-key-using-jq","question_title":"Acting on the existence or non-existence of a key using JQ","question_owner":"jago","answer_owner":"peak","answer_id":38337572,"question_score":6,"reviewed":true,"paraphrase_of":"so-38335869","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-38495941","request":"Convert the string value of the 'value' field to a number and divide it by 1024 raised to the power of 4.","command":"jq '(.value | tonumber) / pow(1024; 4)'","input_text":"{\"value\": \"43165913081459\", \"name\": \"AvailableStorage\"}","expected_output":"39.259169244777695\n","validation_input":"{\"value\": \"1099511627776\", \"name\": \"TestStorage\"}","validation_output":"1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38495941/using-exponential-powers-in-jq","question_title":"Using exponential powers in jq","question_owner":"michaelcoyote","answer_owner":"Jeff Mercado","answer_id":38496753,"question_score":5,"reviewed":true} {"id":"so-38495941-p1","request":"Parse the 'value' field as a number and divide it by 1024 to the power of 4.","command":"jq '(.value | tonumber) / pow(1024; 4)'","input_text":"{\"value\": \"43165913081459\", \"name\": \"AvailableStorage\"}","expected_output":"39.259169244777695\n","validation_input":"{\"value\": \"1099511627776\", \"name\": \"TestStorage\"}","validation_output":"1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38495941/using-exponential-powers-in-jq","question_title":"Using exponential powers in jq","question_owner":"michaelcoyote","answer_owner":"Jeff Mercado","answer_id":38496753,"question_score":5,"reviewed":true,"paraphrase_of":"so-38495941","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-39320865","request":"Transform a JSON array of objects by modifying the 'expire' property: if it is an object containing a '$value' key, replace it with that value; if it is a number, keep it; otherwise set it to null.","command":"jq 'map(.expire |= (if type == \"object\" then .[\"$value\"] elif type == \"number\" then . else null end))'","input_text":"[\n {\n \"name\": \"val1\",\n \"expire\": { \"$value\": 10 }\n },\n {\n \"name\": \"val2\",\n \"expire\": 20\n },\n {\n \"name\": \"val3\"\n }\n]","expected_output":"[\n {\n \"name\": \"val1\",\n \"expire\": 10\n },\n {\n \"name\": \"val2\",\n \"expire\": 20\n },\n {\n \"name\": \"val3\",\n \"expire\": null\n }\n]\n","validation_input":"[\n {\n \"name\": \"itemA\",\n \"expire\": { \"$value\": 50 }\n },\n {\n \"name\": \"itemB\",\n \"expire\": 100\n },\n {\n \"name\": \"itemC\"\n },\n {\n \"name\": \"itemD\",\n \"expire\": \"string_value\"\n }\n]","validation_output":"[\n {\n \"name\": \"itemA\",\n \"expire\": 50\n },\n {\n \"name\": \"itemB\",\n \"expire\": 100\n },\n {\n \"name\": \"itemC\",\n \"expire\": null\n },\n {\n \"name\": \"itemD\",\n \"expire\": null\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39320865/modify-object-properties-conditionally-with-jq","question_title":"Modify object properties conditionally with jq","question_owner":"dr.tyrion","answer_owner":"peak","answer_id":39321021,"question_score":8,"reviewed":true} {"id":"so-39320865-p1","request":"Normalize the 'expire' property: extract the '$value' if it is an object, keep it if it is a number, or set to null otherwise.","command":"jq 'map(.expire |= (if type == \"object\" then .[\"$value\"] elif type == \"number\" then . else null end))'","input_text":"[\n {\n \"name\": \"val1\",\n \"expire\": { \"$value\": 10 }\n },\n {\n \"name\": \"val2\",\n \"expire\": 20\n },\n {\n \"name\": \"val3\"\n }\n]","expected_output":"[\n {\n \"name\": \"val1\",\n \"expire\": 10\n },\n {\n \"name\": \"val2\",\n \"expire\": 20\n },\n {\n \"name\": \"val3\",\n \"expire\": null\n }\n]\n","validation_input":"[\n {\n \"name\": \"itemA\",\n \"expire\": { \"$value\": 50 }\n },\n {\n \"name\": \"itemB\",\n \"expire\": 100\n },\n {\n \"name\": \"itemC\"\n },\n {\n \"name\": \"itemD\",\n \"expire\": \"string_value\"\n }\n]","validation_output":"[\n {\n \"name\": \"itemA\",\n \"expire\": 50\n },\n {\n \"name\": \"itemB\",\n \"expire\": 100\n },\n {\n \"name\": \"itemC\",\n \"expire\": null\n },\n {\n \"name\": \"itemD\",\n \"expire\": null\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39320865/modify-object-properties-conditionally-with-jq","question_title":"Modify object properties conditionally with jq","question_owner":"dr.tyrion","answer_owner":"peak","answer_id":39321021,"question_score":8,"reviewed":true,"paraphrase_of":"so-39320865","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-39914570","request":"Select the address of each node that has at least one attribute with required set to true.","command":"jq '.nodes[] | select(any(.attributes[]; .required == true)) | .address'","input_text":"{\"nodes\":[{\"address\":\"1.1.1.1\",\"attributes\":[{\"id\":\"a\",\"required\":true}]},{\"address\":\"2.2.2.2\",\"attributes\":[{\"id\":\"b\",\"required\":false}]}]}","expected_output":"\"1.1.1.1\"\n","validation_input":"{\"nodes\":[{\"address\":\"10.0.0.1\",\"attributes\":[{\"id\":\"x\",\"required\":false},{\"id\":\"y\",\"required\":true}]},{\"address\":\"10.0.0.2\",\"attributes\":[{\"id\":\"z\",\"required\":false}]}]}","validation_output":"\"10.0.0.1\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39914570/jq-select-attribute-if-any-array-element-satisfies-a-condition","question_title":"jq select attribute if any array element satisfies a condition","question_owner":"Peter Lutz","answer_owner":"peak","answer_id":39923609,"question_score":9,"reviewed":true} {"id":"so-39914570-p1","request":"Retrieve the address for each node possessing at least one attribute where required is true.","command":"jq '.nodes[] | select(any(.attributes[]; .required == true)) | .address'","input_text":"{\"nodes\":[{\"address\":\"1.1.1.1\",\"attributes\":[{\"id\":\"a\",\"required\":true}]},{\"address\":\"2.2.2.2\",\"attributes\":[{\"id\":\"b\",\"required\":false}]}]}","expected_output":"\"1.1.1.1\"\n","validation_input":"{\"nodes\":[{\"address\":\"10.0.0.1\",\"attributes\":[{\"id\":\"x\",\"required\":false},{\"id\":\"y\",\"required\":true}]},{\"address\":\"10.0.0.2\",\"attributes\":[{\"id\":\"z\",\"required\":false}]}]}","validation_output":"\"10.0.0.1\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39914570/jq-select-attribute-if-any-array-element-satisfies-a-condition","question_title":"jq select attribute if any array element satisfies a condition","question_owner":"Peter Lutz","answer_owner":"peak","answer_id":39923609,"question_score":9,"reviewed":true,"paraphrase_of":"so-39914570","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-39994652","request":"Given a JSON array of objects, each with a 'key' and a 'value' field, transform it into a single JSON object. The keys of this object should be the unique 'key' values from the input, and the corresponding values should be arrays containing all 'value' fields associated with that key in the original order.","command":"jq 'reduce .[] as $item ({}; .[$item.key] += [$item.value])'","input_text":"[{\"key\":\"1\",\"value\":\"value 1\"},{\"key\":\"2\",\"value\":\"value 2\"},{\"key\":\"1\",\"value\":\"value 3\"}]","expected_output":"{\n \"1\": [\n \"value 1\",\n \"value 3\"\n ],\n \"2\": [\n \"value 2\"\n ]\n}\n","validation_input":"[{\"key\":\"a\",\"value\":\"x\"},{\"key\":\"b\",\"value\":\"y\"},{\"key\":\"a\",\"value\":\"z\"},{\"key\":\"b\",\"value\":\"w\"}]","validation_output":"{\n \"a\": [\n \"x\",\n \"z\"\n ],\n \"b\": [\n \"y\",\n \"w\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39994652/jq-reduce-array-of-objects-to-object-adding-to-array","question_title":"JQ: Reduce array of objects to object, adding to array","question_owner":"Alex","answer_owner":"peak","answer_id":40004786,"question_score":10,"reviewed":true} {"id":"so-39994652-p1","request":"Group the input objects by their 'key' field into a single object, where each unique key maps to an ordered array of its associated 'value' entries.","command":"jq 'reduce .[] as $item ({}; .[$item.key] += [$item.value])'","input_text":"[{\"key\":\"1\",\"value\":\"value 1\"},{\"key\":\"2\",\"value\":\"value 2\"},{\"key\":\"1\",\"value\":\"value 3\"}]","expected_output":"{\n \"1\": [\n \"value 1\",\n \"value 3\"\n ],\n \"2\": [\n \"value 2\"\n ]\n}\n","validation_input":"[{\"key\":\"a\",\"value\":\"x\"},{\"key\":\"b\",\"value\":\"y\"},{\"key\":\"a\",\"value\":\"z\"},{\"key\":\"b\",\"value\":\"w\"}]","validation_output":"{\n \"a\": [\n \"x\",\n \"z\"\n ],\n \"b\": [\n \"y\",\n \"w\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39994652/jq-reduce-array-of-objects-to-object-adding-to-array","question_title":"JQ: Reduce array of objects to object, adding to array","question_owner":"Alex","answer_owner":"peak","answer_id":40004786,"question_score":10,"reviewed":true,"paraphrase_of":"so-39994652","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-40845789","request":"Transform a JSON object with string keys and nested objects containing a 'name' field into a stream of objects, each mapping the original key to the corresponding name.","command":"jq 'to_entries[] | {(.key): .value.name}'","input_text":"{\"123\": {\"name\": \"Horst\"}, \"789\": {\"name\": \"Bob\"}}","expected_output":"{\n \"123\": \"Horst\"\n}\n{\n \"789\": \"Bob\"\n}\n","validation_input":"{\"id1\": {\"name\": \"Alice\"}, \"id2\": {\"name\": \"Charlie\"}}","validation_output":"{\n \"id1\": \"Alice\"\n}\n{\n \"id2\": \"Charlie\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40845789/how-to-select-key-and-sub-object-property-via-jq","question_title":"How to select key and sub-object property via jq?","question_owner":"k0pernikus","answer_owner":"Cardenalero","answer_id":40846880,"question_score":5,"reviewed":true} {"id":"so-40845789-p1","request":"Convert the input object into a stream of mappings, linking each string key to the 'name' field of its nested object.","command":"jq 'to_entries[] | {(.key): .value.name}'","input_text":"{\"123\": {\"name\": \"Horst\"}, \"789\": {\"name\": \"Bob\"}}","expected_output":"{\n \"123\": \"Horst\"\n}\n{\n \"789\": \"Bob\"\n}\n","validation_input":"{\"id1\": {\"name\": \"Alice\"}, \"id2\": {\"name\": \"Charlie\"}}","validation_output":"{\n \"id1\": \"Alice\"\n}\n{\n \"id2\": \"Charlie\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40845789/how-to-select-key-and-sub-object-property-via-jq","question_title":"How to select key and sub-object property via jq?","question_owner":"k0pernikus","answer_owner":"Cardenalero","answer_id":40846880,"question_score":5,"reviewed":true,"paraphrase_of":"so-40845789","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41111477","request":"Filter an object to keep only the key-value pairs where the value is an array containing the string \"svc\".","command":"jq 'with_entries(select(any(.value[]; . == \"svc\")))'","input_text":"{\"ContentKey--4-0-47--Vovb1BQ\":[\"infra\",\"qa\",\"qa-ContentKey-4-0-47-Vovb1BQ\",\"internal-qa-Conten-WebServi-19E4PUWHRGD44-460820639.us-east-1.elb.amazonaws.com\",\"plan--default\"],\"ContentKey--4-0-47--zjOkiQ\":[\"svc\",\"dev\",\"dev-ContentKey-4-0-47-zjOkiQ\",\"dev-Conte-WebServi-KXJXZBDY113W-2116785917.us-east-1.elb.amazonaws.com\",\"plan--default\"],\"IdGenService--2001-4-22--CJUFaMQ\":[\"svc\",\"dev\",\"dev-IdGenService-2001-4-22-CJUFaMQ\",\"dev-IdGen-WebServi-R7RVXSYAV92W-304073075.us-east-1.elb.amazonaws.com\"],\"IdGenService--2001-4-22--Uhf9CTQ\":[\"svc\",\"qa\",\"qa-IdGenService-2001-4-22-Uhf9CTQ\",\"internal-qa-IdGenS-WebServi-RT5BI5EEVZP3-665537643.us-east-1.elb.amazonaws.com\"]}","expected_output":"{\n \"ContentKey--4-0-47--zjOkiQ\": [\n \"svc\",\n \"dev\",\n \"dev-ContentKey-4-0-47-zjOkiQ\",\n \"dev-Conte-WebServi-KXJXZBDY113W-2116785917.us-east-1.elb.amazonaws.com\",\n \"plan--default\"\n ],\n \"IdGenService--2001-4-22--CJUFaMQ\": [\n \"svc\",\n \"dev\",\n \"dev-IdGenService-2001-4-22-CJUFaMQ\",\n \"dev-IdGen-WebServi-R7RVXSYAV92W-304073075.us-east-1.elb.amazonaws.com\"\n ],\n \"IdGenService--2001-4-22--Uhf9CTQ\": [\n \"svc\",\n \"qa\",\n \"qa-IdGenService-2001-4-22-Uhf9CTQ\",\n \"internal-qa-IdGenS-WebServi-RT5BI5EEVZP3-665537643.us-east-1.elb.amazonaws.com\"\n ]\n}\n","validation_input":"{\"key1\":[\"svc\",\"other\"],\"key2\":[\"no_match\"],\"key3\":[\"foo\",\"svc\",\"bar\"],\"key4\":[]}","validation_output":"{\n \"key1\": [\n \"svc\",\n \"other\"\n ],\n \"key3\": [\n \"foo\",\n \"svc\",\n \"bar\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41111477/jq-find-keys-whose-value-is-an-array-containing-a-specific-element","question_title":"jq find keys whose value is an array containing a specific element","question_owner":"mg03","answer_owner":"Jeff Mercado","answer_id":41111516,"question_score":5,"reviewed":true} {"id":"so-41111477-p1","request":"Retain only those key-value pairs from the object where the value is an array that includes the string \"svc\".","command":"jq 'with_entries(select(any(.value[]; . == \"svc\")))'","input_text":"{\"ContentKey--4-0-47--Vovb1BQ\":[\"infra\",\"qa\",\"qa-ContentKey-4-0-47-Vovb1BQ\",\"internal-qa-Conten-WebServi-19E4PUWHRGD44-460820639.us-east-1.elb.amazonaws.com\",\"plan--default\"],\"ContentKey--4-0-47--zjOkiQ\":[\"svc\",\"dev\",\"dev-ContentKey-4-0-47-zjOkiQ\",\"dev-Conte-WebServi-KXJXZBDY113W-2116785917.us-east-1.elb.amazonaws.com\",\"plan--default\"],\"IdGenService--2001-4-22--CJUFaMQ\":[\"svc\",\"dev\",\"dev-IdGenService-2001-4-22-CJUFaMQ\",\"dev-IdGen-WebServi-R7RVXSYAV92W-304073075.us-east-1.elb.amazonaws.com\"],\"IdGenService--2001-4-22--Uhf9CTQ\":[\"svc\",\"qa\",\"qa-IdGenService-2001-4-22-Uhf9CTQ\",\"internal-qa-IdGenS-WebServi-RT5BI5EEVZP3-665537643.us-east-1.elb.amazonaws.com\"]}","expected_output":"{\n \"ContentKey--4-0-47--zjOkiQ\": [\n \"svc\",\n \"dev\",\n \"dev-ContentKey-4-0-47-zjOkiQ\",\n \"dev-Conte-WebServi-KXJXZBDY113W-2116785917.us-east-1.elb.amazonaws.com\",\n \"plan--default\"\n ],\n \"IdGenService--2001-4-22--CJUFaMQ\": [\n \"svc\",\n \"dev\",\n \"dev-IdGenService-2001-4-22-CJUFaMQ\",\n \"dev-IdGen-WebServi-R7RVXSYAV92W-304073075.us-east-1.elb.amazonaws.com\"\n ],\n \"IdGenService--2001-4-22--Uhf9CTQ\": [\n \"svc\",\n \"qa\",\n \"qa-IdGenService-2001-4-22-Uhf9CTQ\",\n \"internal-qa-IdGenS-WebServi-RT5BI5EEVZP3-665537643.us-east-1.elb.amazonaws.com\"\n ]\n}\n","validation_input":"{\"key1\":[\"svc\",\"other\"],\"key2\":[\"no_match\"],\"key3\":[\"foo\",\"svc\",\"bar\"],\"key4\":[]}","validation_output":"{\n \"key1\": [\n \"svc\",\n \"other\"\n ],\n \"key3\": [\n \"foo\",\n \"svc\",\n \"bar\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41111477/jq-find-keys-whose-value-is-an-array-containing-a-specific-element","question_title":"jq find keys whose value is an array containing a specific element","question_owner":"mg03","answer_owner":"Jeff Mercado","answer_id":41111516,"question_score":5,"reviewed":true,"paraphrase_of":"so-41111477","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41150539","request":"Given a JSON object containing a \"blockdevices\" array, recursively find all objects that do not have a \"children\" key and output their \"name\" field as raw strings, one per line.","command":"jq -r '.blockdevices[] | .. | objects | select(has(\"children\")|not) | .name'","input_text":"{\"blockdevices\":[{\"name\":\"sda\",\"mountpoint\":null,\"children\":[{\"name\":\"sda1\",\"mountpoint\":\"/mnt\"},{\"name\":\"sda2\",\"mountpoint\":null,\"children\":[{\"name\":\"sda2_map\",\"mountpoint\":\"/data\"}]}]},{\"name\":\"sdb\",\"mountpoint\":null}]}","expected_output":"sda1\nsda2_map\nsdb\n","validation_input":"{\"blockdevices\":[{\"name\":\"vda\",\"mountpoint\":null,\"children\":[{\"name\":\"vda1\",\"mountpoint\":\"/boot\"}]},{\"name\":\"vdb\",\"mountpoint\":null,\"children\":[{\"name\":\"vdb1\",\"mountpoint\":null,\"children\":[{\"name\":\"vdb1_part\",\"mountpoint\":\"/home\"}]}]},{\"name\":\"vdc\",\"mountpoint\":\"/var\"}]}","validation_output":"vda1\nvdb1_part\nvdc\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41150539/parsing-json-format-with-jq","question_title":"Parsing JSON format with jq","question_owner":"user4918296","answer_owner":"chepner","answer_id":41151246,"question_score":5,"reviewed":true} {"id":"so-41150539-p1","request":"Recursively traverse a JSON object's \"blockdevices\" array to locate all items lacking a \"children\" key, then print their \"name\" values as raw strings on separate lines.","command":"jq -r '.blockdevices[] | .. | objects | select(has(\"children\")|not) | .name'","input_text":"{\"blockdevices\":[{\"name\":\"sda\",\"mountpoint\":null,\"children\":[{\"name\":\"sda1\",\"mountpoint\":\"/mnt\"},{\"name\":\"sda2\",\"mountpoint\":null,\"children\":[{\"name\":\"sda2_map\",\"mountpoint\":\"/data\"}]}]},{\"name\":\"sdb\",\"mountpoint\":null}]}","expected_output":"sda1\nsda2_map\nsdb\n","validation_input":"{\"blockdevices\":[{\"name\":\"vda\",\"mountpoint\":null,\"children\":[{\"name\":\"vda1\",\"mountpoint\":\"/boot\"}]},{\"name\":\"vdb\",\"mountpoint\":null,\"children\":[{\"name\":\"vdb1\",\"mountpoint\":null,\"children\":[{\"name\":\"vdb1_part\",\"mountpoint\":\"/home\"}]}]},{\"name\":\"vdc\",\"mountpoint\":\"/var\"}]}","validation_output":"vda1\nvdb1_part\nvdc\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41150539/parsing-json-format-with-jq","question_title":"Parsing JSON format with jq","question_owner":"user4918296","answer_owner":"chepner","answer_id":41151246,"question_score":5,"reviewed":true,"paraphrase_of":"so-41150539","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41195915","request":"From an object where values are nested objects containing a 'show_id', remove any entry where 'show_id' equals 1641788.","command":"jq 'with_entries(select(.value.show_id != 1641788))'","input_text":"{\n \"10000703\": {\n \"show_id\": 1641788\n },\n \"10000838\": {\n \"show_id\": 1517903\n },\n \"10001325\": {\n \"show_id\": 1641788\n }\n}","expected_output":"{\n \"10000838\": {\n \"show_id\": 1517903\n }\n}\n","validation_input":"{\n \"key1\": {\n \"show_id\": 123\n },\n \"key2\": {\n \"show_id\": 1641788\n },\n \"key3\": {\n \"show_id\": 456\n },\n \"key4\": {\n \"show_id\": 1641788\n }\n}","validation_output":"{\n \"key1\": {\n \"show_id\": 123\n },\n \"key3\": {\n \"show_id\": 456\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41195915/looking-for-a-jq-filter-to-exclude-nested-objects-based-on-the-value-of-a-nested","question_title":"Looking for a jq filter to exclude nested objects based on the value of a nested property","question_owner":"Garrett Boatman","answer_owner":"peak","answer_id":41200053,"question_score":5,"reviewed":true} {"id":"so-41195915-p1","request":"Filter out any entries from an object of nested values where the inner 'show_id' is equal to 1641788.","command":"jq 'with_entries(select(.value.show_id != 1641788))'","input_text":"{\n \"10000703\": {\n \"show_id\": 1641788\n },\n \"10000838\": {\n \"show_id\": 1517903\n },\n \"10001325\": {\n \"show_id\": 1641788\n }\n}","expected_output":"{\n \"10000838\": {\n \"show_id\": 1517903\n }\n}\n","validation_input":"{\n \"key1\": {\n \"show_id\": 123\n },\n \"key2\": {\n \"show_id\": 1641788\n },\n \"key3\": {\n \"show_id\": 456\n },\n \"key4\": {\n \"show_id\": 1641788\n }\n}","validation_output":"{\n \"key1\": {\n \"show_id\": 123\n },\n \"key3\": {\n \"show_id\": 456\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41195915/looking-for-a-jq-filter-to-exclude-nested-objects-based-on-the-value-of-a-nested","question_title":"Looking for a jq filter to exclude nested objects based on the value of a nested property","question_owner":"Garrett Boatman","answer_owner":"peak","answer_id":41200053,"question_score":5,"reviewed":true,"paraphrase_of":"so-41195915","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41369121","request":"Add the object {\"baz\": [\"bing\", \"bop\"]} to any nested object within the 'foobar' structure that has a key 'A' with value 1, while preserving the rest of the JSON structure.","command":"jq '(.. | select(type == \"object\" and .A == 1)) |= . + {\"baz\": [\"bing\", \"bop\"]}'","input_text":"{\"foobar\":{\"a\":{\"adkjfe\":{\"A\":1,\"foo\":\"bar\"}},\"b\":{\"ekjaei\":{\"A\":2,\"bar\":\"foo\"}}}}","expected_output":"{\n \"foobar\": {\n \"a\": {\n \"adkjfe\": {\n \"A\": 1,\n \"foo\": \"bar\",\n \"baz\": [\n \"bing\",\n \"bop\"\n ]\n }\n },\n \"b\": {\n \"ekjaei\": {\n \"A\": 2,\n \"bar\": \"foo\"\n }\n }\n }\n}\n","validation_input":"{\"foobar\":{\"x\":{\"y\":{\"A\":1,\"z\":true}},\"w\":{\"v\":{\"A\":0}}}}","validation_output":"{\n \"foobar\": {\n \"x\": {\n \"y\": {\n \"A\": 1,\n \"z\": true,\n \"baz\": [\n \"bing\",\n \"bop\"\n ]\n }\n },\n \"w\": {\n \"v\": {\n \"A\": 0\n }\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41369121/modifying-nested-json-conditionally-using-jq","question_title":"Modifying nested json conditionally using jq","question_owner":"dbarnett","answer_owner":"Bertrand Martel","answer_id":41369992,"question_score":5,"reviewed":true} {"id":"so-41369121-p1","request":"Insert {\"baz\": [\"bing\", \"bop\"]} into every nested object inside the 'foobar' structure that contains a key 'A' set to 1, ensuring the rest of the JSON remains intact.","command":"jq '(.. | select(type == \"object\" and .A == 1)) |= . + {\"baz\": [\"bing\", \"bop\"]}'","input_text":"{\"foobar\":{\"a\":{\"adkjfe\":{\"A\":1,\"foo\":\"bar\"}},\"b\":{\"ekjaei\":{\"A\":2,\"bar\":\"foo\"}}}}","expected_output":"{\n \"foobar\": {\n \"a\": {\n \"adkjfe\": {\n \"A\": 1,\n \"foo\": \"bar\",\n \"baz\": [\n \"bing\",\n \"bop\"\n ]\n }\n },\n \"b\": {\n \"ekjaei\": {\n \"A\": 2,\n \"bar\": \"foo\"\n }\n }\n }\n}\n","validation_input":"{\"foobar\":{\"x\":{\"y\":{\"A\":1,\"z\":true}},\"w\":{\"v\":{\"A\":0}}}}","validation_output":"{\n \"foobar\": {\n \"x\": {\n \"y\": {\n \"A\": 1,\n \"z\": true,\n \"baz\": [\n \"bing\",\n \"bop\"\n ]\n }\n },\n \"w\": {\n \"v\": {\n \"A\": 0\n }\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41369121/modifying-nested-json-conditionally-using-jq","question_title":"Modifying nested json conditionally using jq","question_owner":"dbarnett","answer_owner":"Bertrand Martel","answer_id":41369992,"question_score":5,"reviewed":true,"paraphrase_of":"so-41369121","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-41386019","request":"For each key in the .indices object, print the key name followed by a colon, a space, and the value found at .primaries.docs.count within that key's object.","command":"jq -r '.indices | to_entries[] | \"\\(.key): \\(.value.primaries.docs.count)\"'","input_text":"{\n \"indices\": {\n \"plan\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 14208\n }\n }\n },\n \"resource\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 1427143\n }\n }\n },\n \"user\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 104475\n }\n }\n }\n }\n}","expected_output":"plan: 14208\nresource: 1427143\nuser: 104475\n","validation_input":"{\n \"indices\": {\n \"index_a\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 100\n }\n }\n },\n \"index_b\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 200\n }\n }\n }\n }\n}","validation_output":"index_a: 100\nindex_b: 200\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41386019/jq-how-to-print-key-not-value-of-key-and-iterate-over-keys-to-print-sub-valu","question_title":"jq - How to print key (not value of key) and iterate over keys to print sub value","question_owner":"David Vasandani","answer_owner":"Andreas Louv","answer_id":41386230,"question_score":9,"reviewed":true} {"id":"so-41386019-p1","request":"Iterate through each key in the .indices object and output the key name, followed by a colon and space, and then the value located at .primaries.docs.count for that specific key.","command":"jq -r '.indices | to_entries[] | \"\\(.key): \\(.value.primaries.docs.count)\"'","input_text":"{\n \"indices\": {\n \"plan\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 14208\n }\n }\n },\n \"resource\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 1427143\n }\n }\n },\n \"user\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 104475\n }\n }\n }\n }\n}","expected_output":"plan: 14208\nresource: 1427143\nuser: 104475\n","validation_input":"{\n \"indices\": {\n \"index_a\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 100\n }\n }\n },\n \"index_b\": {\n \"primaries\": {\n \"docs\": {\n \"count\": 200\n }\n }\n }\n }\n}","validation_output":"index_a: 100\nindex_b: 200\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/41386019/jq-how-to-print-key-not-value-of-key-and-iterate-over-keys-to-print-sub-valu","question_title":"jq - How to print key (not value of key) and iterate over keys to print sub value","question_owner":"David Vasandani","answer_owner":"Andreas Louv","answer_id":41386230,"question_score":9,"reviewed":true,"paraphrase_of":"so-41386019","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-42227949","request":"Remove all objects from the input array where the value of the 'key' field is exactly 'something'.","command":"jq 'map(select(.key != \"something\"))'","input_text":"[\n {\n \"key\": \"something\",\n \"value\": \"something\"\n },\n {\n \"key\": \"another thing\",\n \"value\": \"another thing\"\n },\n {\n \"key\": \"something\",\n \"value\": \"something\"\n }\n]","expected_output":"[\n {\n \"key\": \"another thing\",\n \"value\": \"another thing\"\n }\n]\n","validation_input":"[\n {\n \"key\": \"foo\",\n \"value\": \"bar\"\n },\n {\n \"key\": \"something\",\n \"value\": \"baz\"\n },\n {\n \"key\": \"qux\",\n \"value\": \"quux\"\n }\n]","validation_output":"[\n {\n \"key\": \"foo\",\n \"value\": \"bar\"\n },\n {\n \"key\": \"qux\",\n \"value\": \"quux\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42227949/jq-testing-a-field-during-walk","question_title":"Jq: testing a field during walk","question_owner":"Kshitiz Sharma","answer_owner":"hek2mgl","answer_id":42228119,"question_score":5,"reviewed":true} {"id":"so-42227949-p1","request":"Delete all objects from the input array that have a 'key' field with the exact value 'something'.","command":"jq 'map(select(.key != \"something\"))'","input_text":"[\n {\n \"key\": \"something\",\n \"value\": \"something\"\n },\n {\n \"key\": \"another thing\",\n \"value\": \"another thing\"\n },\n {\n \"key\": \"something\",\n \"value\": \"something\"\n }\n]","expected_output":"[\n {\n \"key\": \"another thing\",\n \"value\": \"another thing\"\n }\n]\n","validation_input":"[\n {\n \"key\": \"foo\",\n \"value\": \"bar\"\n },\n {\n \"key\": \"something\",\n \"value\": \"baz\"\n },\n {\n \"key\": \"qux\",\n \"value\": \"quux\"\n }\n]","validation_output":"[\n {\n \"key\": \"foo\",\n \"value\": \"bar\"\n },\n {\n \"key\": \"qux\",\n \"value\": \"quux\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42227949/jq-testing-a-field-during-walk","question_title":"Jq: testing a field during walk","question_owner":"Kshitiz Sharma","answer_owner":"hek2mgl","answer_id":42228119,"question_score":5,"reviewed":true,"paraphrase_of":"so-42227949","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-42355182","request":"Replace all occurrences of '.' with ':' in the 'Name' field of each object within the 'Parameters' array.","command":"jq '(.Parameters[].Name) |= (split(\".\") | join(\":\"))'","input_text":"{\"Parameters\":[{\"Name\":\"TEST.AB.SOMETHING\",\"Value\":\"hvfuycsgvfiwbiwbibibewfiwbcfwifcbwibcibc\"},{\"Name\":\"TEST_GF_USER\",\"Value\":\"ssssecret\"}]}","expected_output":"{\n \"Parameters\": [\n {\n \"Name\": \"TEST:AB:SOMETHING\",\n \"Value\": \"hvfuycsgvfiwbiwbibibewfiwbcfwifcbwibcibc\"\n },\n {\n \"Name\": \"TEST_GF_USER\",\n \"Value\": \"ssssecret\"\n }\n ]\n}\n","validation_input":"{\"Parameters\":[{\"Name\":\"A.B.C\",\"Value\":\"1\"},{\"Name\":\"X_Y\",\"Value\":\"2\"},{\"Name\":\"D.E.F.G\",\"Value\":\"3\"}]}","validation_output":"{\n \"Parameters\": [\n {\n \"Name\": \"A:B:C\",\n \"Value\": \"1\"\n },\n {\n \"Name\": \"X_Y\",\n \"Value\": \"2\"\n },\n {\n \"Name\": \"D:E:F:G\",\n \"Value\": \"3\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42355182/substitute-certain-characters-in-strings-found-in-an-object","question_title":"substitute certain characters in strings found in an object","question_owner":"lorem","answer_owner":"hek2mgl","answer_id":42355445,"question_score":5,"reviewed":true} {"id":"so-42355182-p1","request":"For every object in the 'Parameters' array, replace all instances of '.' with ':' in the 'Name' field.","command":"jq '(.Parameters[].Name) |= (split(\".\") | join(\":\"))'","input_text":"{\"Parameters\":[{\"Name\":\"TEST.AB.SOMETHING\",\"Value\":\"hvfuycsgvfiwbiwbibibewfiwbcfwifcbwibcibc\"},{\"Name\":\"TEST_GF_USER\",\"Value\":\"ssssecret\"}]}","expected_output":"{\n \"Parameters\": [\n {\n \"Name\": \"TEST:AB:SOMETHING\",\n \"Value\": \"hvfuycsgvfiwbiwbibibewfiwbcfwifcbwibcibc\"\n },\n {\n \"Name\": \"TEST_GF_USER\",\n \"Value\": \"ssssecret\"\n }\n ]\n}\n","validation_input":"{\"Parameters\":[{\"Name\":\"A.B.C\",\"Value\":\"1\"},{\"Name\":\"X_Y\",\"Value\":\"2\"},{\"Name\":\"D.E.F.G\",\"Value\":\"3\"}]}","validation_output":"{\n \"Parameters\": [\n {\n \"Name\": \"A:B:C\",\n \"Value\": \"1\"\n },\n {\n \"Name\": \"X_Y\",\n \"Value\": \"2\"\n },\n {\n \"Name\": \"D:E:F:G\",\n \"Value\": \"3\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42355182/substitute-certain-characters-in-strings-found-in-an-object","question_title":"substitute certain characters in strings found in an object","question_owner":"lorem","answer_owner":"hek2mgl","answer_id":42355445,"question_score":5,"reviewed":true,"paraphrase_of":"so-42355182","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-42356536","request":"Convert a flat JSON object into a properties file format where each key-value pair is on a new line as key=value.","command":"jq -r 'to_entries[]|\"\\(.key)=\\(.value)\"'","input_text":"{\"foo\": \"bar\", \"abc\": \"def ghi\"}\n","expected_output":"foo=bar\nabc=def ghi\n","validation_input":"{\"name\": \"John\", \"age\": \"30\"}\n","validation_output":"name=John\nage=30\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42356536/convert-a-simple-json-object-to-a-properties-file","question_title":"Convert a simple JSON object to a properties file","question_owner":"lorem","answer_owner":"hek2mgl","answer_id":42356580,"question_score":5,"reviewed":true} {"id":"so-42356536-p1","request":"Transform a flat JSON object into a properties file format, listing each key-value pair on a new line as key=value.","command":"jq -r 'to_entries[]|\"\\(.key)=\\(.value)\"'","input_text":"{\"foo\": \"bar\", \"abc\": \"def ghi\"}\n","expected_output":"foo=bar\nabc=def ghi\n","validation_input":"{\"name\": \"John\", \"age\": \"30\"}\n","validation_output":"name=John\nage=30\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42356536/convert-a-simple-json-object-to-a-properties-file","question_title":"Convert a simple JSON object to a properties file","question_owner":"lorem","answer_owner":"hek2mgl","answer_id":42356580,"question_score":5,"reviewed":true,"paraphrase_of":"so-42356536","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-42846102","request":"Extract specific fields from the '_source' object within each hit of an Elasticsearch response and output them as CSV rows with headers 'customer_name', 'customer_app_version', 'customer_num_apps', 'app_memory_capacity_bytes', and 'app_disk_size_bytes'.","command":"jq -r '.hits.hits[]._source | [.customer_name, .customer_app_version, .customer_num_apps, .app_memory_capacity_bytes, .app_disk_size_bytes] | @csv'","input_text":"{\n \"hits\": {\n \"hits\": [\n {\n \"_source\": {\n \"customer_app_version\": \"el7.20150513\",\n \"customer_num_apps\": 3,\n \"app_memory_capacity_bytes\": 405248409600,\n \"customer_name\": \"Timbuktu Inc\",\n \"app_disk_size_bytes\": 25117047875604\n }\n },\n {\n \"_source\": {\n \"customer_app_version\": \"el4.20150513\",\n \"customer_num_apps\": 34,\n \"app_memory_capacity_bytes\": 58923439600,\n \"customer_name\": \"Bunnies Inc\",\n \"app_disk_size_bytes\": 36517984275604\n }\n }\n ]\n }\n}","expected_output":"\"Timbuktu Inc\",\"el7.20150513\",3,405248409600,25117047875604\n\"Bunnies Inc\",\"el4.20150513\",34,58923439600,36517984275604\n","validation_input":"{\n \"hits\": {\n \"hits\": [\n {\n \"_source\": {\n \"customer_app_version\": \"v1.0\",\n \"customer_num_apps\": 1,\n \"app_memory_capacity_bytes\": 1024,\n \"customer_name\": \"Test Corp\",\n \"app_disk_size_bytes\": 2048\n }\n }\n ]\n }\n}","validation_output":"\"Test Corp\",\"v1.0\",1,1024,2048\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42846102/extracting-data-from-source-document-in-elasticsearch-results-with-jq","question_title":"Extracting data from _source document in ElasticSearch results with jq","question_owner":"Sam G","answer_owner":"Charles Duffy","answer_id":42846175,"question_score":5,"reviewed":true} {"id":"so-42846102-p1","request":"Parse an Elasticsearch response to extract specific fields from the '_source' of each hit, formatting them as CSV rows with the headers: 'customer_name', 'customer_app_version', 'customer_num_apps', 'app_memory_capacity_bytes', and 'app_disk_size_bytes'.","command":"jq -r '.hits.hits[]._source | [.customer_name, .customer_app_version, .customer_num_apps, .app_memory_capacity_bytes, .app_disk_size_bytes] | @csv'","input_text":"{\n \"hits\": {\n \"hits\": [\n {\n \"_source\": {\n \"customer_app_version\": \"el7.20150513\",\n \"customer_num_apps\": 3,\n \"app_memory_capacity_bytes\": 405248409600,\n \"customer_name\": \"Timbuktu Inc\",\n \"app_disk_size_bytes\": 25117047875604\n }\n },\n {\n \"_source\": {\n \"customer_app_version\": \"el4.20150513\",\n \"customer_num_apps\": 34,\n \"app_memory_capacity_bytes\": 58923439600,\n \"customer_name\": \"Bunnies Inc\",\n \"app_disk_size_bytes\": 36517984275604\n }\n }\n ]\n }\n}","expected_output":"\"Timbuktu Inc\",\"el7.20150513\",3,405248409600,25117047875604\n\"Bunnies Inc\",\"el4.20150513\",34,58923439600,36517984275604\n","validation_input":"{\n \"hits\": {\n \"hits\": [\n {\n \"_source\": {\n \"customer_app_version\": \"v1.0\",\n \"customer_num_apps\": 1,\n \"app_memory_capacity_bytes\": 1024,\n \"customer_name\": \"Test Corp\",\n \"app_disk_size_bytes\": 2048\n }\n }\n ]\n }\n}","validation_output":"\"Test Corp\",\"v1.0\",1,1024,2048\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42846102/extracting-data-from-source-document-in-elasticsearch-results-with-jq","question_title":"Extracting data from _source document in ElasticSearch results with jq","question_owner":"Sam G","answer_owner":"Charles Duffy","answer_id":42846175,"question_score":5,"reviewed":true,"paraphrase_of":"so-42846102","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-43379692","request":"Extract the dot-separated paths of all leaf nodes (scalars) from a JSON object.","command":"jq '[paths(scalars) | map(tostring) | join(\".\")]'","input_text":"{\"name\": \"tom\", \"age\": 12, \"visits\": {\"2017-01-25\": 3, \"2016-07-26\": 4}}","expected_output":"[\n \"name\",\n \"age\",\n \"visits.2017-01-25\",\n \"visits.2016-07-26\"\n]\n","validation_input":"{\"a\": 1, \"b\": {\"c\": \"d\", \"e\": null}}","validation_output":"[\n \"a\",\n \"b.c\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43379692/extract-schema-of-nested-json-object","question_title":"Extract schema of nested JSON object","question_owner":"nik","answer_owner":"peak","answer_id":43380040,"question_score":10,"reviewed":true} {"id":"so-43379692-p1","request":"Generate dot-separated paths for all leaf nodes (scalar values) found within a JSON object.","command":"jq '[paths(scalars) | map(tostring) | join(\".\")]'","input_text":"{\"name\": \"tom\", \"age\": 12, \"visits\": {\"2017-01-25\": 3, \"2016-07-26\": 4}}","expected_output":"[\n \"name\",\n \"age\",\n \"visits.2017-01-25\",\n \"visits.2016-07-26\"\n]\n","validation_input":"{\"a\": 1, \"b\": {\"c\": \"d\", \"e\": null}}","validation_output":"[\n \"a\",\n \"b.c\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43379692/extract-schema-of-nested-json-object","question_title":"Extract schema of nested JSON object","question_owner":"nik","answer_owner":"peak","answer_id":43380040,"question_score":10,"reviewed":true,"paraphrase_of":"so-43379692","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-43397216","request":"From a JSON array of resource objects, each containing a 'Tags' array of key-value pairs, select the objects that have a tag with Key 'hc-class' and Value 'staging-standalone'.","command":"jq '.[] | select(any(.Tags[]; .Key == \"hc-class\" and .Value == \"staging-standalone\"))'","input_text":"[{\"PublicIpAddress\": \"11.22.33.44\", \"PrivateIpAddress\": \"55.66.77.88\", \"Tags\": [{\"Value\": \"live199.blah.com\", \"Key\": \"Name\"}, {\"Value\": \"live-standalone\", \"Key\": \"hc-class\"}]}, {\"PublicIpAddress\": \"111.222.333.444\", \"PrivateIpAddress\": \"555.666.777.888\", \"Tags\": [{\"Value\": \"staging99.blah.com\", \"Key\": \"Name\"}, {\"Value\": \"staging-standalone\", \"Key\": \"hc-class\"}]}]","expected_output":"{\n \"PublicIpAddress\": \"111.222.333.444\",\n \"PrivateIpAddress\": \"555.666.777.888\",\n \"Tags\": [\n {\n \"Value\": \"staging99.blah.com\",\n \"Key\": \"Name\"\n },\n {\n \"Value\": \"staging-standalone\",\n \"Key\": \"hc-class\"\n }\n ]\n}\n","validation_input":"[{\"id\": \"res-1\", \"Tags\": [{\"Key\": \"Environment\", \"Value\": \"prod\"}]}, {\"id\": \"res-2\", \"Tags\": [{\"Key\": \"hc-class\", \"Value\": \"staging-standalone\"}, {\"Key\": \"Name\", \"Value\": \"web-server\"}]}]","validation_output":"{\n \"id\": \"res-2\",\n \"Tags\": [\n {\n \"Key\": \"hc-class\",\n \"Value\": \"staging-standalone\"\n },\n {\n \"Key\": \"Name\",\n \"Value\": \"web-server\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43397216/filter-array-with-jq-based-on-nested-values","question_title":"Filter array with jq based on nested values","question_owner":"bhu Boue vidya","answer_owner":"peak","answer_id":43398788,"question_score":6,"reviewed":true} {"id":"so-43397216-p1","request":"From a JSON array of resources, filter for objects containing a 'Tags' entry where the Key is 'hc-class' and the Value is 'staging-standalone'.","command":"jq '.[] | select(any(.Tags[]; .Key == \"hc-class\" and .Value == \"staging-standalone\"))'","input_text":"[{\"PublicIpAddress\": \"11.22.33.44\", \"PrivateIpAddress\": \"55.66.77.88\", \"Tags\": [{\"Value\": \"live199.blah.com\", \"Key\": \"Name\"}, {\"Value\": \"live-standalone\", \"Key\": \"hc-class\"}]}, {\"PublicIpAddress\": \"111.222.333.444\", \"PrivateIpAddress\": \"555.666.777.888\", \"Tags\": [{\"Value\": \"staging99.blah.com\", \"Key\": \"Name\"}, {\"Value\": \"staging-standalone\", \"Key\": \"hc-class\"}]}]","expected_output":"{\n \"PublicIpAddress\": \"111.222.333.444\",\n \"PrivateIpAddress\": \"555.666.777.888\",\n \"Tags\": [\n {\n \"Value\": \"staging99.blah.com\",\n \"Key\": \"Name\"\n },\n {\n \"Value\": \"staging-standalone\",\n \"Key\": \"hc-class\"\n }\n ]\n}\n","validation_input":"[{\"id\": \"res-1\", \"Tags\": [{\"Key\": \"Environment\", \"Value\": \"prod\"}]}, {\"id\": \"res-2\", \"Tags\": [{\"Key\": \"hc-class\", \"Value\": \"staging-standalone\"}, {\"Key\": \"Name\", \"Value\": \"web-server\"}]}]","validation_output":"{\n \"id\": \"res-2\",\n \"Tags\": [\n {\n \"Key\": \"hc-class\",\n \"Value\": \"staging-standalone\"\n },\n {\n \"Key\": \"Name\",\n \"Value\": \"web-server\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43397216/filter-array-with-jq-based-on-nested-values","question_title":"Filter array with jq based on nested values","question_owner":"bhu Boue vidya","answer_owner":"peak","answer_id":43398788,"question_score":6,"reviewed":true,"paraphrase_of":"so-43397216","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-43729643","request":"Transform the 'Env' array within the 'Config' object of each element in the input array. Convert the array of 'KEY=VALUE' strings into an object where keys are the variable names and values are the corresponding values.","command":"jq '[.[] | .Config.Env |= (map(split(\"=\") | {(.[0]): .[1]}) | add)]'","input_text":"[\n {\n \"Config\": {\n \"Env\": [\n \"JENKINS_HOST=1.2.3.4\",\n \"JENKINS_INSTANCE=tea\",\n \"JENKINS_NAME=Enterprise Architecture Tools\",\n \"JENKINS_VERSION=2.46.2\",\n \"JENKINS_PROTOCOL=http\"\n ]\n }\n }\n]","expected_output":"[\n {\n \"Config\": {\n \"Env\": {\n \"JENKINS_HOST\": \"1.2.3.4\",\n \"JENKINS_INSTANCE\": \"tea\",\n \"JENKINS_NAME\": \"Enterprise Architecture Tools\",\n \"JENKINS_VERSION\": \"2.46.2\",\n \"JENKINS_PROTOCOL\": \"http\"\n }\n }\n }\n]\n","validation_input":"[\n {\n \"Config\": {\n \"Env\": [\n \"DB_HOST=localhost\",\n \"DB_PORT=5432\"\n ]\n }\n },\n {\n \"Config\": {\n \"Env\": [\n \"API_KEY=abc123\"\n ]\n }\n }\n]","validation_output":"[\n {\n \"Config\": {\n \"Env\": {\n \"DB_HOST\": \"localhost\",\n \"DB_PORT\": \"5432\"\n }\n }\n },\n {\n \"Config\": {\n \"Env\": {\n \"API_KEY\": \"abc123\"\n }\n }\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43729643/use-jq-to-turn-x-y-pairs-into-key-value-pairs","question_title":"Use jq to turn x=y pairs into key/value pairs","question_owner":"Ken Pronovici","answer_owner":"peak","answer_id":43729713,"question_score":6,"reviewed":true} {"id":"so-43729643-p1","request":"Convert the 'Env' array of 'KEY=VALUE' strings within the 'Config' object of each input element into an object mapping variable names to their values.","command":"jq '[.[] | .Config.Env |= (map(split(\"=\") | {(.[0]): .[1]}) | add)]'","input_text":"[\n {\n \"Config\": {\n \"Env\": [\n \"JENKINS_HOST=1.2.3.4\",\n \"JENKINS_INSTANCE=tea\",\n \"JENKINS_NAME=Enterprise Architecture Tools\",\n \"JENKINS_VERSION=2.46.2\",\n \"JENKINS_PROTOCOL=http\"\n ]\n }\n }\n]","expected_output":"[\n {\n \"Config\": {\n \"Env\": {\n \"JENKINS_HOST\": \"1.2.3.4\",\n \"JENKINS_INSTANCE\": \"tea\",\n \"JENKINS_NAME\": \"Enterprise Architecture Tools\",\n \"JENKINS_VERSION\": \"2.46.2\",\n \"JENKINS_PROTOCOL\": \"http\"\n }\n }\n }\n]\n","validation_input":"[\n {\n \"Config\": {\n \"Env\": [\n \"DB_HOST=localhost\",\n \"DB_PORT=5432\"\n ]\n }\n },\n {\n \"Config\": {\n \"Env\": [\n \"API_KEY=abc123\"\n ]\n }\n }\n]","validation_output":"[\n {\n \"Config\": {\n \"Env\": {\n \"DB_HOST\": \"localhost\",\n \"DB_PORT\": \"5432\"\n }\n }\n },\n {\n \"Config\": {\n \"Env\": {\n \"API_KEY\": \"abc123\"\n }\n }\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43729643/use-jq-to-turn-x-y-pairs-into-key-value-pairs","question_title":"Use jq to turn x=y pairs into key/value pairs","question_owner":"Ken Pronovici","answer_owner":"peak","answer_id":43729713,"question_score":6,"reviewed":true,"paraphrase_of":"so-43729643","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44410394","request":"Update the id field to \"NEWID\" for all objects in the values array where the name field starts with \"test\".","command":"jq '(.values) |= (map(if .name | startswith(\"test\") then .id = \"NEWID\" else . end))'","input_text":"{\"other-value\":\"some-id\",\"values\":[{\"name\":\"test-2017-12-01\",\"id\":\"1\"},{\"name\":\"othert\",\"id\":\"2\"}]}","expected_output":"{\n \"other-value\": \"some-id\",\n \"values\": [\n {\n \"name\": \"test-2017-12-01\",\n \"id\": \"NEWID\"\n },\n {\n \"name\": \"othert\",\n \"id\": \"2\"\n }\n ]\n}\n","validation_input":"{\"other-value\":\"x\",\"values\":[{\"name\":\"test-abc\",\"id\":\"10\"},{\"name\":\"prod-xyz\",\"id\":\"20\"},{\"name\":\"test-def\",\"id\":\"30\"}]}","validation_output":"{\n \"other-value\": \"x\",\n \"values\": [\n {\n \"name\": \"test-abc\",\n \"id\": \"NEWID\"\n },\n {\n \"name\": \"prod-xyz\",\n \"id\": \"20\"\n },\n {\n \"name\": \"test-def\",\n \"id\": \"NEWID\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44410394/using-jq-to-update-objects-within-a-json-document-if-the-value-corresponding-to","question_title":"Using jq to update objects within a JSON document if the value corresponding to a given key starts with a specified string","question_owner":"manixx","answer_owner":"hek2mgl","answer_id":44411730,"question_score":9,"reviewed":true} {"id":"so-44410394-p1","request":"Change the id field to \"NEWID\" for every object in the values array whose name field begins with \"test\".","command":"jq '(.values) |= (map(if .name | startswith(\"test\") then .id = \"NEWID\" else . end))'","input_text":"{\"other-value\":\"some-id\",\"values\":[{\"name\":\"test-2017-12-01\",\"id\":\"1\"},{\"name\":\"othert\",\"id\":\"2\"}]}","expected_output":"{\n \"other-value\": \"some-id\",\n \"values\": [\n {\n \"name\": \"test-2017-12-01\",\n \"id\": \"NEWID\"\n },\n {\n \"name\": \"othert\",\n \"id\": \"2\"\n }\n ]\n}\n","validation_input":"{\"other-value\":\"x\",\"values\":[{\"name\":\"test-abc\",\"id\":\"10\"},{\"name\":\"prod-xyz\",\"id\":\"20\"},{\"name\":\"test-def\",\"id\":\"30\"}]}","validation_output":"{\n \"other-value\": \"x\",\n \"values\": [\n {\n \"name\": \"test-abc\",\n \"id\": \"NEWID\"\n },\n {\n \"name\": \"prod-xyz\",\n \"id\": \"20\"\n },\n {\n \"name\": \"test-def\",\n \"id\": \"NEWID\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44410394/using-jq-to-update-objects-within-a-json-document-if-the-value-corresponding-to","question_title":"Using jq to update objects within a JSON document if the value corresponding to a given key starts with a specified string","question_owner":"manixx","answer_owner":"hek2mgl","answer_id":44411730,"question_score":9,"reviewed":true,"paraphrase_of":"so-44410394","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44439671","request":"Transform a JSON object by replacing each nested object with the value of its 'value' field.","command":"jq 'map_values(.value)'","input_text":"{\"a\": {\"sensitive\": false, \"type\": \"string\", \"value\": \"mykeypair\"}, \"b\": {\"sensitive\": false, \"type\": \"string\", \"value\": \"123\"}}","expected_output":"{\n \"a\": \"mykeypair\",\n \"b\": \"123\"\n}\n","validation_input":"{\"x\": {\"sensitive\": true, \"type\": \"int\", \"value\": \"456\"}, \"y\": {\"sensitive\": false, \"type\": \"bool\", \"value\": \"true\"}}","validation_output":"{\n \"x\": \"456\",\n \"y\": \"true\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44439671/jq-nested-dictionary-parser-and-extract-key","question_title":"jq - nested dictionary parser and extract key","question_owner":"ptou","answer_owner":"Jeff Mercado","answer_id":44440931,"question_score":5,"reviewed":true} {"id":"so-44439671-p1","request":"Replace every nested object in a JSON structure with the content of its 'value' property.","command":"jq 'map_values(.value)'","input_text":"{\"a\": {\"sensitive\": false, \"type\": \"string\", \"value\": \"mykeypair\"}, \"b\": {\"sensitive\": false, \"type\": \"string\", \"value\": \"123\"}}","expected_output":"{\n \"a\": \"mykeypair\",\n \"b\": \"123\"\n}\n","validation_input":"{\"x\": {\"sensitive\": true, \"type\": \"int\", \"value\": \"456\"}, \"y\": {\"sensitive\": false, \"type\": \"bool\", \"value\": \"true\"}}","validation_output":"{\n \"x\": \"456\",\n \"y\": \"true\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44439671/jq-nested-dictionary-parser-and-extract-key","question_title":"jq - nested dictionary parser and extract key","question_owner":"ptou","answer_owner":"Jeff Mercado","answer_id":44440931,"question_score":5,"reviewed":true,"paraphrase_of":"so-44439671","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44812062","request":"Combine a stream of JSON objects into a single JSON array.","command":"jq -s .","input_text":"{\"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"ItmId\": \"1694738780\"}\n{\"ReferringUrl\": \"L\", \"OpenAccess\": \"1\", \"ItmId\": \"1347809133\"}","expected_output":"[\n {\n \"ReferringUrl\": \"N\",\n \"OpenAccess\": \"0\",\n \"ItmId\": \"1694738780\"\n },\n {\n \"ReferringUrl\": \"L\",\n \"OpenAccess\": \"1\",\n \"ItmId\": \"1347809133\"\n }\n]\n","validation_input":"{\"status\": \"ok\", \"code\": 200}\n{\"status\": \"error\", \"code\": 500}\n{\"status\": \"pending\", \"code\": 100}","validation_output":"[\n {\n \"status\": \"ok\",\n \"code\": 200\n },\n {\n \"status\": \"error\",\n \"code\": 500\n },\n {\n \"status\": \"pending\",\n \"code\": 100\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44812062/how-concatenate-multiple-json-objects-with-a-delimiter-comma-using-jq","question_title":"How concatenate multiple json objects with a delimiter comma using jq","question_owner":"Eleanor","answer_owner":"peak","answer_id":44813170,"question_score":9,"reviewed":true} {"id":"so-44812062-p1","request":"Merge a sequence of JSON objects into one consolidated JSON array.","command":"jq -s .","input_text":"{\"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"ItmId\": \"1694738780\"}\n{\"ReferringUrl\": \"L\", \"OpenAccess\": \"1\", \"ItmId\": \"1347809133\"}","expected_output":"[\n {\n \"ReferringUrl\": \"N\",\n \"OpenAccess\": \"0\",\n \"ItmId\": \"1694738780\"\n },\n {\n \"ReferringUrl\": \"L\",\n \"OpenAccess\": \"1\",\n \"ItmId\": \"1347809133\"\n }\n]\n","validation_input":"{\"status\": \"ok\", \"code\": 200}\n{\"status\": \"error\", \"code\": 500}\n{\"status\": \"pending\", \"code\": 100}","validation_output":"[\n {\n \"status\": \"ok\",\n \"code\": 200\n },\n {\n \"status\": \"error\",\n \"code\": 500\n },\n {\n \"status\": \"pending\",\n \"code\": 100\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44812062/how-concatenate-multiple-json-objects-with-a-delimiter-comma-using-jq","question_title":"How concatenate multiple json objects with a delimiter comma using jq","question_owner":"Eleanor","answer_owner":"peak","answer_id":44813170,"question_score":9,"reviewed":true,"paraphrase_of":"so-44812062","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44832475","request":"Read a JSON array of usage records from stdin. Select and output only those records where at least one item in the 'Items' array has an 'Origin' field equal to 'Alert'.","command":"jq '[.[] | select(any(.Items[]; .Origin == \"Alert\"))]'","input_text":"[{\"time\": \"2017-06-10 00:00:48-0400,317\", \"UserInfo\": {\"AppId\": \"ONE_SEARCH\", \"UsageGroupId\": \"92600\"}, \"Items\": [{\"PublicationCode\": \"\", \"OpenUrlRefId\": \"\", \"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"ItmId\": \"1328515516\"}]}, {\"time\": \"2017-06-10 00:00:48-0400,548\", \"UserInfo\": {\"AppId\": \"DIALOG\", \"UsageGroupId\": \"1195735\"}, \"Items\": [{\"Origin\": \"Alert\", \"PublicationCode\": \"\", \"NumberOfCopies\": 1, \"ItmId\": \"1907446549\"}, {\"Origin\": \"Alert\", \"PublicationCode\": \"\", \"NumberOfCopies\": 1, \"ItmId\": \"1907446950\"}]}]","expected_output":"[\n {\n \"time\": \"2017-06-10 00:00:48-0400,548\",\n \"UserInfo\": {\n \"AppId\": \"DIALOG\",\n \"UsageGroupId\": \"1195735\"\n },\n \"Items\": [\n {\n \"Origin\": \"Alert\",\n \"PublicationCode\": \"\",\n \"NumberOfCopies\": 1,\n \"ItmId\": \"1907446549\"\n },\n {\n \"Origin\": \"Alert\",\n \"PublicationCode\": \"\",\n \"NumberOfCopies\": 1,\n \"ItmId\": \"1907446950\"\n }\n ]\n }\n]\n","validation_input":"[{\"time\": \"T1\", \"UserInfo\": {\"AppId\": \"A1\"}, \"Items\": [{\"Origin\": \"Search\", \"ItmId\": \"1\"}]}, {\"time\": \"T2\", \"UserInfo\": {\"AppId\": \"A2\"}, \"Items\": [{\"Origin\": \"Alert\", \"ItmId\": \"2\"}, {\"Origin\": \"Search\", \"ItmId\": \"3\"}]}]","validation_output":"[\n {\n \"time\": \"T2\",\n \"UserInfo\": {\n \"AppId\": \"A2\"\n },\n \"Items\": [\n {\n \"Origin\": \"Alert\",\n \"ItmId\": \"2\"\n },\n {\n \"Origin\": \"Search\",\n \"ItmId\": \"3\"\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44832475/jq-select-objects-that-have-specific-value-in-nested-json-bash","question_title":"jq select objects that have specific value in nested json bash","question_owner":"Eleanor","answer_owner":"peak","answer_id":44833420,"question_score":5,"reviewed":true} {"id":"so-44832475-p1","request":"Read usage records from stdin as a JSON array and output only those entries containing at least one item in the 'Items' list with an 'Origin' of 'Alert'.","command":"jq '[.[] | select(any(.Items[]; .Origin == \"Alert\"))]'","input_text":"[{\"time\": \"2017-06-10 00:00:48-0400,317\", \"UserInfo\": {\"AppId\": \"ONE_SEARCH\", \"UsageGroupId\": \"92600\"}, \"Items\": [{\"PublicationCode\": \"\", \"OpenUrlRefId\": \"\", \"ReferringUrl\": \"N\", \"OpenAccess\": \"0\", \"ItmId\": \"1328515516\"}]}, {\"time\": \"2017-06-10 00:00:48-0400,548\", \"UserInfo\": {\"AppId\": \"DIALOG\", \"UsageGroupId\": \"1195735\"}, \"Items\": [{\"Origin\": \"Alert\", \"PublicationCode\": \"\", \"NumberOfCopies\": 1, \"ItmId\": \"1907446549\"}, {\"Origin\": \"Alert\", \"PublicationCode\": \"\", \"NumberOfCopies\": 1, \"ItmId\": \"1907446950\"}]}]","expected_output":"[\n {\n \"time\": \"2017-06-10 00:00:48-0400,548\",\n \"UserInfo\": {\n \"AppId\": \"DIALOG\",\n \"UsageGroupId\": \"1195735\"\n },\n \"Items\": [\n {\n \"Origin\": \"Alert\",\n \"PublicationCode\": \"\",\n \"NumberOfCopies\": 1,\n \"ItmId\": \"1907446549\"\n },\n {\n \"Origin\": \"Alert\",\n \"PublicationCode\": \"\",\n \"NumberOfCopies\": 1,\n \"ItmId\": \"1907446950\"\n }\n ]\n }\n]\n","validation_input":"[{\"time\": \"T1\", \"UserInfo\": {\"AppId\": \"A1\"}, \"Items\": [{\"Origin\": \"Search\", \"ItmId\": \"1\"}]}, {\"time\": \"T2\", \"UserInfo\": {\"AppId\": \"A2\"}, \"Items\": [{\"Origin\": \"Alert\", \"ItmId\": \"2\"}, {\"Origin\": \"Search\", \"ItmId\": \"3\"}]}]","validation_output":"[\n {\n \"time\": \"T2\",\n \"UserInfo\": {\n \"AppId\": \"A2\"\n },\n \"Items\": [\n {\n \"Origin\": \"Alert\",\n \"ItmId\": \"2\"\n },\n {\n \"Origin\": \"Search\",\n \"ItmId\": \"3\"\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44832475/jq-select-objects-that-have-specific-value-in-nested-json-bash","question_title":"jq select objects that have specific value in nested json bash","question_owner":"Eleanor","answer_owner":"peak","answer_id":44833420,"question_score":5,"reviewed":true,"paraphrase_of":"so-44832475","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-44985737","request":"Given a JSON object with nested properties where some keys are numeric strings (e.g., \"1\"), extract the value located at the path .e[\"1\"].f and output it as raw text.","command":"jq -r '.e[\"1\"].f'","input_text":"{\"a\":\"b\",\"c\":\"d\",\"e\":{\"1\":{\"f\":\"g\",\"h\":\"i\"}}}","expected_output":"g\n","validation_input":"{\"a\":\"x\",\"e\":{\"1\":{\"f\":\"target_value\",\"h\":\"j\"},\"2\":{\"f\":\"other\"}}}","validation_output":"target_value\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44985737/invalid-numeric-literal-with-jq","question_title":"Invalid numeric literal with jq","question_owner":"Gaius","answer_owner":"Bertrand Martel","answer_id":44987362,"question_score":10,"reviewed":true} {"id":"so-44985737-p1","request":"Retrieve the value at path .e[\"1\"].f from a JSON object featuring numeric string keys and print it as plain text.","command":"jq -r '.e[\"1\"].f'","input_text":"{\"a\":\"b\",\"c\":\"d\",\"e\":{\"1\":{\"f\":\"g\",\"h\":\"i\"}}}","expected_output":"g\n","validation_input":"{\"a\":\"x\",\"e\":{\"1\":{\"f\":\"target_value\",\"h\":\"j\"},\"2\":{\"f\":\"other\"}}}","validation_output":"target_value\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44985737/invalid-numeric-literal-with-jq","question_title":"Invalid numeric literal with jq","question_owner":"Gaius","answer_owner":"Bertrand Martel","answer_id":44987362,"question_score":10,"reviewed":true,"paraphrase_of":"so-44985737","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-45747895","request":"Given a JSON object with a field \"some_array\" containing an array of objects, update the value of the \"k2\" key to \"changed\" for every object where the \"k1\" key is equal to \"B\", leaving other objects unchanged.","command":"jq '.some_array |= map(if .k1==\"B\" then .k2=\"changed\" else . end)'","input_text":"{\"some_array\": [{\"k1\": \"A\", \"k2\": \"XXX\"}, {\"k1\": \"B\", \"k2\": \"YYY\"}]}","expected_output":"{\n \"some_array\": [\n {\n \"k1\": \"A\",\n \"k2\": \"XXX\"\n },\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n }\n ]\n}\n","validation_input":"{\"some_array\": [{\"k1\": \"B\", \"k2\": \"old_val\"}, {\"k1\": \"C\", \"k2\": \"keep\"}, {\"k1\": \"B\", \"k2\": \"another_old\"}]}","validation_output":"{\n \"some_array\": [\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n },\n {\n \"k1\": \"C\",\n \"k2\": \"keep\"\n },\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45747895/how-do-i-update-a-single-value-in-a-nested-array-of-objects-in-a-json-document-u","question_title":"How do I update a single value in a nested array of objects in a json document using jq?","question_owner":"zayquan","answer_owner":"jq170727","answer_id":45748203,"question_score":6,"reviewed":true} {"id":"so-45747895-p1","request":"For each object in the \"some_array\" field of a JSON object, change \"k2\" to \"changed\" if \"k1\" equals \"B\", while keeping all other objects intact.","command":"jq '.some_array |= map(if .k1==\"B\" then .k2=\"changed\" else . end)'","input_text":"{\"some_array\": [{\"k1\": \"A\", \"k2\": \"XXX\"}, {\"k1\": \"B\", \"k2\": \"YYY\"}]}","expected_output":"{\n \"some_array\": [\n {\n \"k1\": \"A\",\n \"k2\": \"XXX\"\n },\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n }\n ]\n}\n","validation_input":"{\"some_array\": [{\"k1\": \"B\", \"k2\": \"old_val\"}, {\"k1\": \"C\", \"k2\": \"keep\"}, {\"k1\": \"B\", \"k2\": \"another_old\"}]}","validation_output":"{\n \"some_array\": [\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n },\n {\n \"k1\": \"C\",\n \"k2\": \"keep\"\n },\n {\n \"k1\": \"B\",\n \"k2\": \"changed\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45747895/how-do-i-update-a-single-value-in-a-nested-array-of-objects-in-a-json-document-u","question_title":"How do I update a single value in a nested array of objects in a json document using jq?","question_owner":"zayquan","answer_owner":"jq170727","answer_id":45748203,"question_score":6,"reviewed":true,"paraphrase_of":"so-45747895","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-45982943","request":"Given a JSON object containing a list of services, where each service has a name and an array of timer records, output one line per timer record. Each line should be a JSON array containing the service name, the timer's datetime, and the timer's value.","command":"jq -c '.services.service[] | .name as $name | .timer[] | [$name, .datetime, .value]'","input_text":"{\"services\":{\"service\":[{\"name\":\"Test Value\",\"timer\":[{\"datetime\":\"08/30/2017 16:33:35\",\"value\":\"625\"},{\"datetime\":\"08/30/2017 16:22:38\",\"value\":\"240\"}]},{\"name\":\"Test Value 2\",\"timer\":[{\"datetime\":\"08/30/2017 16:07:38\",\"value\":\"432\"},{\"datetime\":\"08/30/2017 15:59:07\",\"value\":\"1355\"}]}]}}","expected_output":"[\"Test Value\",\"08/30/2017 16:33:35\",\"625\"]\n[\"Test Value\",\"08/30/2017 16:22:38\",\"240\"]\n[\"Test Value 2\",\"08/30/2017 16:07:38\",\"432\"]\n[\"Test Value 2\",\"08/30/2017 15:59:07\",\"1355\"]\n","validation_input":"{\"services\":{\"service\":[{\"name\":\"Service A\",\"timer\":[{\"datetime\":\"01/01/2020 10:00:00\",\"value\":\"100\"}]},{\"name\":\"Service B\",\"timer\":[{\"datetime\":\"01/01/2020 11:00:00\",\"value\":\"200\"},{\"datetime\":\"01/01/2020 12:00:00\",\"value\":\"300\"}]}]}}","validation_output":"[\"Service A\",\"01/01/2020 10:00:00\",\"100\"]\n[\"Service B\",\"01/01/2020 11:00:00\",\"200\"]\n[\"Service B\",\"01/01/2020 12:00:00\",\"300\"]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45982943/jq-get-each-value-in-array-with-parent","question_title":"jq get each value in array with parent","question_owner":"Glen Solsberry","answer_owner":"MichaÅ‚ Politowski","answer_id":45984077,"question_score":10,"reviewed":true} {"id":"so-46796701","request":"Reorder the keys of a JSON object so that a specific key named 'shouldbeFirstKey' appears first, while preserving the relative order of other keys and recursively applying this to nested objects.","command":"jq 'def reorder(order): . as $in | if type == \"object\" then reduce (keys_unsorted|order)[] as $key({}; . + { ($key): ($in[$key] | reorder(order)) }) elif type == \"array\" then map( reorder(order) ) else . end; def neworder: \"shouldbeFirstKey\" as $s | index($s) as $i | if $i==null then . else [$s] + .[:$i] + .[$i+1:] end; reorder(neworder)'","input_text":"{\"key1\": \"value\", \"shouldbeFirstKey\": \"value2\", \"other\": {\"key3\": \"value3\", \"shouldbeFirstKey\": \"value4\"}}","expected_output":"{\n \"shouldbeFirstKey\": \"value2\",\n \"key1\": \"value\",\n \"other\": {\n \"shouldbeFirstKey\": \"value4\",\n \"key3\": \"value3\"\n }\n}\n","validation_input":"{\"alpha\": 1, \"shouldbeFirstKey\": 2, \"beta\": {\"gamma\": 3, \"shouldbeFirstKey\": 4, \"delta\": 5}}","validation_output":"{\n \"shouldbeFirstKey\": 2,\n \"alpha\": 1,\n \"beta\": {\n \"shouldbeFirstKey\": 4,\n \"gamma\": 3,\n \"delta\": 5\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46796701/jq-sorting-key-by-arbitrary-order","question_title":"JQ sorting key by arbitrary order","question_owner":"Astro","answer_owner":"jq170727","answer_id":46797833,"question_score":5,"reviewed":true} {"id":"so-46796701-p1","request":"Recursively reorder keys in a JSON object so that 'shouldbeFirstKey' is always first, maintaining the original relative order for all other keys.","command":"jq 'def reorder(order): . as $in | if type == \"object\" then reduce (keys_unsorted|order)[] as $key({}; . + { ($key): ($in[$key] | reorder(order)) }) elif type == \"array\" then map( reorder(order) ) else . end; def neworder: \"shouldbeFirstKey\" as $s | index($s) as $i | if $i==null then . else [$s] + .[:$i] + .[$i+1:] end; reorder(neworder)'","input_text":"{\"key1\": \"value\", \"shouldbeFirstKey\": \"value2\", \"other\": {\"key3\": \"value3\", \"shouldbeFirstKey\": \"value4\"}}","expected_output":"{\n \"shouldbeFirstKey\": \"value2\",\n \"key1\": \"value\",\n \"other\": {\n \"shouldbeFirstKey\": \"value4\",\n \"key3\": \"value3\"\n }\n}\n","validation_input":"{\"alpha\": 1, \"shouldbeFirstKey\": 2, \"beta\": {\"gamma\": 3, \"shouldbeFirstKey\": 4, \"delta\": 5}}","validation_output":"{\n \"shouldbeFirstKey\": 2,\n \"alpha\": 1,\n \"beta\": {\n \"shouldbeFirstKey\": 4,\n \"gamma\": 3,\n \"delta\": 5\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46796701/jq-sorting-key-by-arbitrary-order","question_title":"JQ sorting key by arbitrary order","question_owner":"Astro","answer_owner":"jq170727","answer_id":46797833,"question_score":5,"reviewed":true,"paraphrase_of":"so-46796701","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-46956201","request":"Extract the 'class' and 'score' from each class in the nested structure images -> classifiers -> classes and format as CSV rows.","command":"jq -r '.images[].classifiers[].classes[] | [.class, .score] | @csv'","input_text":"{\"custom_classes\": 2, \"images\": [{\"classifiers\": [{\"classes\": [{\"class\": \"football\", \"score\": 0.867376}], \"classifier_id\": \"players_1\", \"name\": \"players\"}], \"image\": \"img1.jpg\"}], \"images_processed\": 1}","expected_output":"\"football\",0.867376\n","validation_input":"{\"custom_classes\": 1, \"images\": [{\"classifiers\": [{\"classes\": [{\"class\": \"car\", \"score\": 0.9}, {\"class\": \"truck\", \"score\": 0.1}], \"classifier_id\": \"c1\", \"name\": \"vehicles\"}], \"image\": \"img2.jpg\"}], \"images_processed\": 1}","validation_output":"\"car\",0.9\n\"truck\",0.1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46956201/parsing-nested-json-with-jq","question_title":"Parsing nested json with jq","question_owner":"Vini","answer_owner":"Oliver Baumann","answer_id":46956950,"question_score":8,"reviewed":true} {"id":"so-46956201-p1","request":"Parse the nested path images -> classifiers -> classes to extract 'class' and 'score' fields, formatting the results as CSV rows.","command":"jq -r '.images[].classifiers[].classes[] | [.class, .score] | @csv'","input_text":"{\"custom_classes\": 2, \"images\": [{\"classifiers\": [{\"classes\": [{\"class\": \"football\", \"score\": 0.867376}], \"classifier_id\": \"players_1\", \"name\": \"players\"}], \"image\": \"img1.jpg\"}], \"images_processed\": 1}","expected_output":"\"football\",0.867376\n","validation_input":"{\"custom_classes\": 1, \"images\": [{\"classifiers\": [{\"classes\": [{\"class\": \"car\", \"score\": 0.9}, {\"class\": \"truck\", \"score\": 0.1}], \"classifier_id\": \"c1\", \"name\": \"vehicles\"}], \"image\": \"img2.jpg\"}], \"images_processed\": 1}","validation_output":"\"car\",0.9\n\"truck\",0.1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46956201/parsing-nested-json-with-jq","question_title":"Parsing nested json with jq","question_owner":"Vini","answer_owner":"Oliver Baumann","answer_id":46956950,"question_score":8,"reviewed":true,"paraphrase_of":"so-46956201","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47012967","request":"Select the host object with hostname 'h6' from the hosts array in the input JSON object.","command":"jq '.hosts[] | select(.hostname==\"h6\")'","input_text":"{\n \"env\": \"DC\",\n \"hosts\": [\n {\n \"apt_update_last_success\": \"1495991703\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h1\"\n },\n {\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n }\n ]\n}","expected_output":"{\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n}\n","validation_input":"{\n \"env\": \"PROD\",\n \"hosts\": [\n {\n \"apt_update_last_success\": \"1000000000\",\n \"architecture\": \"arm64\",\n \"hostname\": \"server1\"\n },\n {\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n }\n ]\n}","validation_output":"{\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47012967/jq-error-cannot-iterate-over-string","question_title":"jq: error: Cannot iterate over string","question_owner":"Chris","answer_owner":"RomanPerekhrest","answer_id":47013146,"question_score":8,"reviewed":true} {"id":"so-47012967-p1","request":"Identify and return the host object with hostname 'h6' from the 'hosts' array within the input JSON.","command":"jq '.hosts[] | select(.hostname==\"h6\")'","input_text":"{\n \"env\": \"DC\",\n \"hosts\": [\n {\n \"apt_update_last_success\": \"1495991703\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h1\"\n },\n {\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n }\n ]\n}","expected_output":"{\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n}\n","validation_input":"{\n \"env\": \"PROD\",\n \"hosts\": [\n {\n \"apt_update_last_success\": \"1000000000\",\n \"architecture\": \"arm64\",\n \"hostname\": \"server1\"\n },\n {\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n }\n ]\n}","validation_output":"{\n \"apt_update_last_success\": \"1496049307\",\n \"architecture\": \"amd64\",\n \"hostname\": \"h6\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47012967/jq-error-cannot-iterate-over-string","question_title":"jq: error: Cannot iterate over string","question_owner":"Chris","answer_owner":"RomanPerekhrest","answer_id":47013146,"question_score":8,"reviewed":true,"paraphrase_of":"so-47012967","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47342084","request":"Update the 'ParameterValue' to 'jess-project' for any object in the array where 'ParameterKey' is 'Project'.","command":"jq 'map(if .ParameterKey == \"Project\" then . + {\"ParameterValue\": \"jess-project\"} else . end)'","input_text":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"old-value\"\n },\n {\n \"ParameterKey\": \"Environment\",\n \"ParameterValue\": \"prod\"\n }\n]","expected_output":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n },\n {\n \"ParameterKey\": \"Environment\",\n \"ParameterValue\": \"prod\"\n }\n]\n","validation_input":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"initial\"\n },\n {\n \"ParameterKey\": \"Other\",\n \"ParameterValue\": \"keep\"\n },\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"another\"\n }\n]","validation_output":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n },\n {\n \"ParameterKey\": \"Other\",\n \"ParameterValue\": \"keep\"\n },\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47342084/jq-error-syntax-error-unexpected-expecting-unix-shell-quoting-issues","question_title":"jq error syntax error, unexpected '=', expecting '}' (Unix shell quoting issues?) at <top-level>","question_owner":"spiderman","answer_owner":"Jacob Krall","answer_id":47342113,"question_score":6,"reviewed":true} {"id":"so-47342084-p1","request":"Set the 'ParameterValue' to 'jess-project' for any array element where the 'ParameterKey' matches 'Project'.","command":"jq 'map(if .ParameterKey == \"Project\" then . + {\"ParameterValue\": \"jess-project\"} else . end)'","input_text":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"old-value\"\n },\n {\n \"ParameterKey\": \"Environment\",\n \"ParameterValue\": \"prod\"\n }\n]","expected_output":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n },\n {\n \"ParameterKey\": \"Environment\",\n \"ParameterValue\": \"prod\"\n }\n]\n","validation_input":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"initial\"\n },\n {\n \"ParameterKey\": \"Other\",\n \"ParameterValue\": \"keep\"\n },\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"another\"\n }\n]","validation_output":"[\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n },\n {\n \"ParameterKey\": \"Other\",\n \"ParameterValue\": \"keep\"\n },\n {\n \"ParameterKey\": \"Project\",\n \"ParameterValue\": \"jess-project\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47342084/jq-error-syntax-error-unexpected-expecting-unix-shell-quoting-issues","question_title":"jq error syntax error, unexpected '=', expecting '}' (Unix shell quoting issues?) at <top-level>","question_owner":"spiderman","answer_owner":"Jacob Krall","answer_id":47342113,"question_score":6,"reviewed":true,"paraphrase_of":"so-47342084","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47420833","request":"Count the number of objects in the 'items' array that do not have a 'charge' key.","command":"jq '[.items[] | select(has(\"charge\") | not)] | length'","input_text":"{\"current_page\": 1, \"items\": [{\"id\": 1, \"name\": \"vehicleA\", \"state\": \"available\", \"charge\": 100}, {\"id\": 2, \"name\": \"vehicleB\", \"state\": \"available\"}, {\"id\": 3, \"name\": \"vehicleC\", \"state\": \"available\", \"charge\": 50}]}","expected_output":"1\n","validation_input":"{\"current_page\": 1, \"items\": [{\"id\": 1, \"name\": \"v1\", \"charge\": null}, {\"id\": 2, \"name\": \"v2\"}, {\"id\": 3, \"name\": \"v3\", \"charge\": 10}]}","validation_output":"1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47420833/count-records-with-missing-keys-using-jq","question_title":"Count records with missing keys using jq","question_owner":"iskandarblue","answer_owner":"jq170727","answer_id":47421029,"question_score":8,"reviewed":true} {"id":"so-47420833-p1","request":"Calculate how many objects in the 'items' array lack a 'charge' key.","command":"jq '[.items[] | select(has(\"charge\") | not)] | length'","input_text":"{\"current_page\": 1, \"items\": [{\"id\": 1, \"name\": \"vehicleA\", \"state\": \"available\", \"charge\": 100}, {\"id\": 2, \"name\": \"vehicleB\", \"state\": \"available\"}, {\"id\": 3, \"name\": \"vehicleC\", \"state\": \"available\", \"charge\": 50}]}","expected_output":"1\n","validation_input":"{\"current_page\": 1, \"items\": [{\"id\": 1, \"name\": \"v1\", \"charge\": null}, {\"id\": 2, \"name\": \"v2\"}, {\"id\": 3, \"name\": \"v3\", \"charge\": 10}]}","validation_output":"1\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47420833/count-records-with-missing-keys-using-jq","question_title":"Count records with missing keys using jq","question_owner":"iskandarblue","answer_owner":"jq170727","answer_id":47421029,"question_score":8,"reviewed":true,"paraphrase_of":"so-47420833","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47421993","request":"From a JSON array of objects, filter for objects where the 'charge' key is null or missing, and then extract only the 'id' value from those objects.","command":"jq 'map(select(.charge == null)) | .[].id'","input_text":"[{\"id\": 1, \"name\": \"vehicleA\", \"state\": \"available\", \"charge\": 100}, {\"id\": 2, \"name\": \"vehicleB\", \"state\": \"available\"}, {\"id\": 3, \"name\": \"vehicleC\", \"state\": \"available\", \"charge\": 50}]","expected_output":"2\n","validation_input":"[{\"id\": 10, \"type\": \"truck\", \"charge\": null}, {\"id\": 20, \"type\": \"car\", \"charge\": 80}]","validation_output":"10\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47421993/get-specific-key-value-pairs-with-jq","question_title":"Get specific key value pairs with jq","question_owner":"iskandarblue","answer_owner":"janos","answer_id":47422063,"question_score":6,"reviewed":true} {"id":"so-47421993-p1","request":"Filter a JSON array for objects where 'charge' is null or absent, then extract only the 'id' from the matching items.","command":"jq 'map(select(.charge == null)) | .[].id'","input_text":"[{\"id\": 1, \"name\": \"vehicleA\", \"state\": \"available\", \"charge\": 100}, {\"id\": 2, \"name\": \"vehicleB\", \"state\": \"available\"}, {\"id\": 3, \"name\": \"vehicleC\", \"state\": \"available\", \"charge\": 50}]","expected_output":"2\n","validation_input":"[{\"id\": 10, \"type\": \"truck\", \"charge\": null}, {\"id\": 20, \"type\": \"car\", \"charge\": 80}]","validation_output":"10\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47421993/get-specific-key-value-pairs-with-jq","question_title":"Get specific key value pairs with jq","question_owner":"iskandarblue","answer_owner":"janos","answer_id":47422063,"question_score":6,"reviewed":true,"paraphrase_of":"so-47421993","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47437773","request":"Read a stream of JSON objects from stdin. For each object that has a 'Customer' field with a 'City' subfield, replace the city name with its corresponding code from a hardcoded mapping where 'Cityname1' maps to 'Code1' and 'Cityname2' maps to 'Code2'. Output the modified stream.","command":"jq 'if .Customer?.City? != null then .Customer.City |= ({\"Cityname1\": \"Code1\", \"Cityname2\": \"Code2\"}[.] // .) else . end'","input_text":"{\"Customer\": {\"CustomerName\": \"Customer1\", \"City\": \"Cityname1\"}}\n{\"RelevantObject\": false}\n{\"Customer\": {\"CustomerName\": \"Customer2\", \"City\": \"Cityname2\"}}","expected_output":"{\n \"Customer\": {\n \"CustomerName\": \"Customer1\",\n \"City\": \"Code1\"\n }\n}\n{\n \"RelevantObject\": false\n}\n{\n \"Customer\": {\n \"CustomerName\": \"Customer2\",\n \"City\": \"Code2\"\n }\n}\n","validation_input":"{\"Customer\": {\"CustomerName\": \"CustA\", \"City\": \"Cityname1\"}}\n{\"Other\": true}\n{\"Customer\": {\"CustomerName\": \"CustB\", \"City\": \"UnknownCity\"}}","validation_output":"{\n \"Customer\": {\n \"CustomerName\": \"CustA\",\n \"City\": \"Code1\"\n }\n}\n{\n \"Other\": true\n}\n{\n \"Customer\": {\n \"CustomerName\": \"CustB\",\n \"City\": \"UnknownCity\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47437773/replacing-values-in-json-using-values-from-another-file-with-jq","question_title":"Replacing values in JSON using values from another file with jq","question_owner":"James Brown","answer_owner":"peak","answer_id":47438214,"question_score":5,"reviewed":true} {"id":"so-47437773-p1","request":"Process a stdin stream of JSON objects: for any object containing a 'Customer' field with a nested 'City', substitute the city name using a fixed map where 'Cityname1' becomes 'Code1' and 'Cityname2' becomes 'Code2', then output the updated stream.","command":"jq 'if .Customer?.City? != null then .Customer.City |= ({\"Cityname1\": \"Code1\", \"Cityname2\": \"Code2\"}[.] // .) else . end'","input_text":"{\"Customer\": {\"CustomerName\": \"Customer1\", \"City\": \"Cityname1\"}}\n{\"RelevantObject\": false}\n{\"Customer\": {\"CustomerName\": \"Customer2\", \"City\": \"Cityname2\"}}","expected_output":"{\n \"Customer\": {\n \"CustomerName\": \"Customer1\",\n \"City\": \"Code1\"\n }\n}\n{\n \"RelevantObject\": false\n}\n{\n \"Customer\": {\n \"CustomerName\": \"Customer2\",\n \"City\": \"Code2\"\n }\n}\n","validation_input":"{\"Customer\": {\"CustomerName\": \"CustA\", \"City\": \"Cityname1\"}}\n{\"Other\": true}\n{\"Customer\": {\"CustomerName\": \"CustB\", \"City\": \"UnknownCity\"}}","validation_output":"{\n \"Customer\": {\n \"CustomerName\": \"CustA\",\n \"City\": \"Code1\"\n }\n}\n{\n \"Other\": true\n}\n{\n \"Customer\": {\n \"CustomerName\": \"CustB\",\n \"City\": \"UnknownCity\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47437773/replacing-values-in-json-using-values-from-another-file-with-jq","question_title":"Replacing values in JSON using values from another file with jq","question_owner":"James Brown","answer_owner":"peak","answer_id":47438214,"question_score":5,"reviewed":true,"paraphrase_of":"so-47437773","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-47730946","request":"Convert an array of objects within a JSON object into CSV format, including a header row derived from the keys of the first object.","command":"jq -r '(.users[0] | keys_unsorted), (.users[] | to_entries | map(.value)) | @csv'","input_text":"{\"users\": [{\"username\": \"jack\", \"email\": \"jack@somewhere.com\", \"total running apps\": \"1\", \"api-mock-app\": \"0\", \"flogo\": \"1\", \"ipaas\": \"0\", \"nodejs-app\": \"0\"}, {\"username\": \"jill\", \"email\": \"jill@somewhere.com\", \"total running apps\": \"1\", \"api-mock-app\": \"0\", \"flogo\": \"1\", \"ipaas\": \"0\", \"nodejs-app\": \"0\"}]}","expected_output":"\"username\",\"email\",\"total running apps\",\"api-mock-app\",\"flogo\",\"ipaas\",\"nodejs-app\"\n\"jack\",\"jack@somewhere.com\",\"1\",\"0\",\"1\",\"0\",\"0\"\n\"jill\",\"jill@somewhere.com\",\"1\",\"0\",\"1\",\"0\",\"0\"\n","validation_input":"{\"users\": [{\"username\": \"tom\", \"email\": \"tom@example.com\", \"total running apps\": \"2\", \"api-mock-app\": \"1\", \"flogo\": \"0\", \"ipaas\": \"1\", \"nodejs-app\": \"0\"}]}","validation_output":"\"username\",\"email\",\"total running apps\",\"api-mock-app\",\"flogo\",\"ipaas\",\"nodejs-app\"\n\"tom\",\"tom@example.com\",\"2\",\"1\",\"0\",\"1\",\"0\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47730946/convert-json-array-into-csv-using-jq","question_title":"Convert JSON array into CSV using jq","question_owner":"Rajiv Rai","answer_owner":"RomanPerekhrest","answer_id":47733020,"question_score":5,"reviewed":true} {"id":"so-47730946-p1","request":"Transform a JSON object's array of objects into CSV format, ensuring the header row is generated from the keys of the first object in the array.","command":"jq -r '(.users[0] | keys_unsorted), (.users[] | to_entries | map(.value)) | @csv'","input_text":"{\"users\": [{\"username\": \"jack\", \"email\": \"jack@somewhere.com\", \"total running apps\": \"1\", \"api-mock-app\": \"0\", \"flogo\": \"1\", \"ipaas\": \"0\", \"nodejs-app\": \"0\"}, {\"username\": \"jill\", \"email\": \"jill@somewhere.com\", \"total running apps\": \"1\", \"api-mock-app\": \"0\", \"flogo\": \"1\", \"ipaas\": \"0\", \"nodejs-app\": \"0\"}]}","expected_output":"\"username\",\"email\",\"total running apps\",\"api-mock-app\",\"flogo\",\"ipaas\",\"nodejs-app\"\n\"jack\",\"jack@somewhere.com\",\"1\",\"0\",\"1\",\"0\",\"0\"\n\"jill\",\"jill@somewhere.com\",\"1\",\"0\",\"1\",\"0\",\"0\"\n","validation_input":"{\"users\": [{\"username\": \"tom\", \"email\": \"tom@example.com\", \"total running apps\": \"2\", \"api-mock-app\": \"1\", \"flogo\": \"0\", \"ipaas\": \"1\", \"nodejs-app\": \"0\"}]}","validation_output":"\"username\",\"email\",\"total running apps\",\"api-mock-app\",\"flogo\",\"ipaas\",\"nodejs-app\"\n\"tom\",\"tom@example.com\",\"2\",\"1\",\"0\",\"1\",\"0\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47730946/convert-json-array-into-csv-using-jq","question_title":"Convert JSON array into CSV using jq","question_owner":"Rajiv Rai","answer_owner":"RomanPerekhrest","answer_id":47733020,"question_score":5,"reviewed":true,"paraphrase_of":"so-47730946","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48077471","request":"Select objects from a JSON array where the numeric value of field 'a' is greater than 50 and the numeric value of field 'b' is greater than 50. The values in the JSON are strings representing numbers.","command":"jq '.[] | select((.a|tonumber) > 50 and (.b|tonumber) > 50)'","input_text":"[\n {\n \"a\": \"0\",\n \"b\": \"66.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n },\n {\n \"a\": \"12.33\",\n \"b\": \"0\",\n \"c\": \"60.2\",\n \"d\": \"19.3\"\n },\n {\n \"a\": \"70.0\",\n \"b\": \"92.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n }\n]","expected_output":"{\n \"a\": \"70.0\",\n \"b\": \"92.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n}\n","validation_input":"[\n {\n \"a\": \"10\",\n \"b\": \"20\",\n \"c\": \"30\",\n \"d\": \"40\"\n },\n {\n \"a\": \"55.5\",\n \"b\": \"55.5\",\n \"c\": \"0\",\n \"d\": \"0\"\n },\n {\n \"a\": \"100\",\n \"b\": \"10\",\n \"c\": \"0\",\n \"d\": \"0\"\n }\n]","validation_output":"{\n \"a\": \"55.5\",\n \"b\": \"55.5\",\n \"c\": \"0\",\n \"d\": \"0\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48077471/parsing-float-value-from-string-by-jq","question_title":"Parsing float value from string by jq","question_owner":"Sakares","answer_owner":"RomanPerekhrest","answer_id":48078423,"question_score":6,"reviewed":true} {"id":"so-48077471-p1","request":"From a JSON array, extract objects where the string-encoded numeric values of fields 'a' and 'b' are both strictly greater than 50.","command":"jq '.[] | select((.a|tonumber) > 50 and (.b|tonumber) > 50)'","input_text":"[\n {\n \"a\": \"0\",\n \"b\": \"66.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n },\n {\n \"a\": \"12.33\",\n \"b\": \"0\",\n \"c\": \"60.2\",\n \"d\": \"19.3\"\n },\n {\n \"a\": \"70.0\",\n \"b\": \"92.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n }\n]","expected_output":"{\n \"a\": \"70.0\",\n \"b\": \"92.67\",\n \"c\": \"0\",\n \"d\": \"0\"\n}\n","validation_input":"[\n {\n \"a\": \"10\",\n \"b\": \"20\",\n \"c\": \"30\",\n \"d\": \"40\"\n },\n {\n \"a\": \"55.5\",\n \"b\": \"55.5\",\n \"c\": \"0\",\n \"d\": \"0\"\n },\n {\n \"a\": \"100\",\n \"b\": \"10\",\n \"c\": \"0\",\n \"d\": \"0\"\n }\n]","validation_output":"{\n \"a\": \"55.5\",\n \"b\": \"55.5\",\n \"c\": \"0\",\n \"d\": \"0\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48077471/parsing-float-value-from-string-by-jq","question_title":"Parsing float value from string by jq","question_owner":"Sakares","answer_owner":"RomanPerekhrest","answer_id":48078423,"question_score":6,"reviewed":true,"paraphrase_of":"so-48077471","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48258020","request":"Transform the 'roles' field in each JSON object: if it is an array, join its elements with a comma; otherwise, keep it as is.","command":"jq '.roles |= if type == \"array\" then join(\",\") else . end'","input_text":"{\"roles\": [\"ADMIN\", \"USER\"], \"user_id\": 100, \"message\": \"abc added a user xyz\", \"level\": \"info\", \"created_at\": \"2014-10-12 14:06:37\"}\n{\"roles\": \"ADMIN\", \"user_id\": 102, \"message\": \"a added a user b\", \"level\": \"info\", \"created_at\": \"2014-10-12 14:06:37\"}","expected_output":"{\n \"roles\": \"ADMIN,USER\",\n \"user_id\": 100,\n \"message\": \"abc added a user xyz\",\n \"level\": \"info\",\n \"created_at\": \"2014-10-12 14:06:37\"\n}\n{\n \"roles\": \"ADMIN\",\n \"user_id\": 102,\n \"message\": \"a added a user b\",\n \"level\": \"info\",\n \"created_at\": \"2014-10-12 14:06:37\"\n}\n","validation_input":"{\"roles\": [\"EDITOR\", \"VIEWER\"], \"user_id\": 200, \"message\": \"test message\", \"level\": \"debug\", \"created_at\": \"2023-01-01 00:00:00\"}\n{\"roles\": \"SUPERADMIN\", \"user_id\": 201, \"message\": \"another message\", \"level\": \"info\", \"created_at\": \"2023-01-02 00:00:00\"}\n{\"roles\": [], \"user_id\": 202, \"message\": \"empty roles\", \"level\": \"warn\", \"created_at\": \"2023-01-03 00:00:00\"}","validation_output":"{\n \"roles\": \"EDITOR,VIEWER\",\n \"user_id\": 200,\n \"message\": \"test message\",\n \"level\": \"debug\",\n \"created_at\": \"2023-01-01 00:00:00\"\n}\n{\n \"roles\": \"SUPERADMIN\",\n \"user_id\": 201,\n \"message\": \"another message\",\n \"level\": \"info\",\n \"created_at\": \"2023-01-02 00:00:00\"\n}\n{\n \"roles\": \"\",\n \"user_id\": 202,\n \"message\": \"empty roles\",\n \"level\": \"warn\",\n \"created_at\": \"2023-01-03 00:00:00\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48258020/transform-a-particular-field-with-jq","question_title":"Transform a particular field with jq","question_owner":"Sumit Jain","answer_owner":"peak","answer_id":48258369,"question_score":5,"reviewed":true} {"id":"so-48258020-p1","request":"Modify the 'roles' field in each JSON object by joining its elements with commas if it is an array, while leaving non-array values untouched.","command":"jq '.roles |= if type == \"array\" then join(\",\") else . end'","input_text":"{\"roles\": [\"ADMIN\", \"USER\"], \"user_id\": 100, \"message\": \"abc added a user xyz\", \"level\": \"info\", \"created_at\": \"2014-10-12 14:06:37\"}\n{\"roles\": \"ADMIN\", \"user_id\": 102, \"message\": \"a added a user b\", \"level\": \"info\", \"created_at\": \"2014-10-12 14:06:37\"}","expected_output":"{\n \"roles\": \"ADMIN,USER\",\n \"user_id\": 100,\n \"message\": \"abc added a user xyz\",\n \"level\": \"info\",\n \"created_at\": \"2014-10-12 14:06:37\"\n}\n{\n \"roles\": \"ADMIN\",\n \"user_id\": 102,\n \"message\": \"a added a user b\",\n \"level\": \"info\",\n \"created_at\": \"2014-10-12 14:06:37\"\n}\n","validation_input":"{\"roles\": [\"EDITOR\", \"VIEWER\"], \"user_id\": 200, \"message\": \"test message\", \"level\": \"debug\", \"created_at\": \"2023-01-01 00:00:00\"}\n{\"roles\": \"SUPERADMIN\", \"user_id\": 201, \"message\": \"another message\", \"level\": \"info\", \"created_at\": \"2023-01-02 00:00:00\"}\n{\"roles\": [], \"user_id\": 202, \"message\": \"empty roles\", \"level\": \"warn\", \"created_at\": \"2023-01-03 00:00:00\"}","validation_output":"{\n \"roles\": \"EDITOR,VIEWER\",\n \"user_id\": 200,\n \"message\": \"test message\",\n \"level\": \"debug\",\n \"created_at\": \"2023-01-01 00:00:00\"\n}\n{\n \"roles\": \"SUPERADMIN\",\n \"user_id\": 201,\n \"message\": \"another message\",\n \"level\": \"info\",\n \"created_at\": \"2023-01-02 00:00:00\"\n}\n{\n \"roles\": \"\",\n \"user_id\": 202,\n \"message\": \"empty roles\",\n \"level\": \"warn\",\n \"created_at\": \"2023-01-03 00:00:00\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48258020/transform-a-particular-field-with-jq","question_title":"Transform a particular field with jq","question_owner":"Sumit Jain","answer_owner":"peak","answer_id":48258369,"question_score":5,"reviewed":true,"paraphrase_of":"so-48258020","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48306264","request":"Sort the 'items' array for each value in a JSON object, handling cases where the 'items' key is missing by leaving the object unchanged.","command":"jq 'map_values(if has(\"items\") then .items |= sort else . end)'","input_text":"{\"alice\": {\"items\": [\"foo\", \"bar\"]}, \"bob\": {\"items\": [\"bar\", \"foo\"]}, \"charlie\": {}}","expected_output":"{\n \"alice\": {\n \"items\": [\n \"bar\",\n \"foo\"\n ]\n },\n \"bob\": {\n \"items\": [\n \"bar\",\n \"foo\"\n ]\n },\n \"charlie\": {}\n}\n","validation_input":"{\"user1\": {\"items\": [\"z\", \"a\"]}, \"user2\": {}, \"user3\": {\"items\": [\"m\"]}}","validation_output":"{\n \"user1\": {\n \"items\": [\n \"a\",\n \"z\"\n ]\n },\n \"user2\": {},\n \"user3\": {\n \"items\": [\n \"m\"\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48306264/how-do-i-sort-a-possibly-absent-array-with-jq","question_title":"How do I sort a possibly-absent array with jq?","question_owner":"Wilfred Hughes","answer_owner":"Jeff Mercado","answer_id":48308247,"question_score":5,"reviewed":true} {"id":"so-48306264-p1","request":"Sort the 'items' array within each value of a JSON object, ensuring that objects lacking the 'items' key remain unmodified.","command":"jq 'map_values(if has(\"items\") then .items |= sort else . end)'","input_text":"{\"alice\": {\"items\": [\"foo\", \"bar\"]}, \"bob\": {\"items\": [\"bar\", \"foo\"]}, \"charlie\": {}}","expected_output":"{\n \"alice\": {\n \"items\": [\n \"bar\",\n \"foo\"\n ]\n },\n \"bob\": {\n \"items\": [\n \"bar\",\n \"foo\"\n ]\n },\n \"charlie\": {}\n}\n","validation_input":"{\"user1\": {\"items\": [\"z\", \"a\"]}, \"user2\": {}, \"user3\": {\"items\": [\"m\"]}}","validation_output":"{\n \"user1\": {\n \"items\": [\n \"a\",\n \"z\"\n ]\n },\n \"user2\": {},\n \"user3\": {\n \"items\": [\n \"m\"\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48306264/how-do-i-sort-a-possibly-absent-array-with-jq","question_title":"How do I sort a possibly-absent array with jq?","question_owner":"Wilfred Hughes","answer_owner":"Jeff Mercado","answer_id":48308247,"question_score":5,"reviewed":true,"paraphrase_of":"so-48306264","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48764829","request":"Convert the values of the input JSON object into a tab-separated values (TSV) row.","command":"jq -r 'to_entries | map(.value) | @tsv'","input_text":"{\"base_price_mw\": 249.99, \"best_offer_base_price\": 280.06, \"name\": \"my product name\", \"status\": 1}","expected_output":"249.99\t280.06\tmy product name\t1\n","validation_input":"{\"id\": 101, \"quantity\": 5, \"label\": \"widget\", \"active\": true}","validation_output":"101\t5\twidget\ttrue\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48764829/jq-cannot-be-tsv-formatted-only-array-error","question_title":"jq cannot be tsv-formatted, only array error","question_owner":"glitchtracker","answer_owner":"hek2mgl","answer_id":48764947,"question_score":9,"reviewed":true} {"id":"so-48764829-p1","request":"Serialize the values of an input JSON object into a single tab-separated values (TSV) row.","command":"jq -r 'to_entries | map(.value) | @tsv'","input_text":"{\"base_price_mw\": 249.99, \"best_offer_base_price\": 280.06, \"name\": \"my product name\", \"status\": 1}","expected_output":"249.99\t280.06\tmy product name\t1\n","validation_input":"{\"id\": 101, \"quantity\": 5, \"label\": \"widget\", \"active\": true}","validation_output":"101\t5\twidget\ttrue\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48764829/jq-cannot-be-tsv-formatted-only-array-error","question_title":"jq cannot be tsv-formatted, only array error","question_owner":"glitchtracker","answer_owner":"hek2mgl","answer_id":48764947,"question_score":9,"reviewed":true,"paraphrase_of":"so-48764829","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48878003","request":"For each JSON object in the input stream, if the 'objectName' field is 'contacts', set the 'IBM' field to 'Y'; otherwise, leave the object unchanged.","command":"jq 'if .objectName == \"contacts\" then .IBM = \"Y\" else . end'","input_text":"{\"Element\": \"acton\", \"objectName\": \"contacts\", \"Path\": \"/contacts\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\", \"clientPhase\": \"\", \"parentPhase\": \"\", \"existsToday\": \"\"}\n{\"Element\": \"acton\", \"objectName\": \"optouts\", \"Path\": \"/optouts\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Dependency\": \"\", \"Gap\": \"\", \"clientPhase\": \"\", \"parentPhase\": \"\", \"existsToday\": \"\"}","expected_output":"{\n \"Element\": \"acton\",\n \"objectName\": \"contacts\",\n \"Path\": \"/contacts\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"Y\",\n \"Gap\": \"\",\n \"clientPhase\": \"\",\n \"parentPhase\": \"\",\n \"existsToday\": \"\"\n}\n{\n \"Element\": \"acton\",\n \"objectName\": \"optouts\",\n \"Path\": \"/optouts\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"\",\n \"Dependency\": \"\",\n \"Gap\": \"\",\n \"clientPhase\": \"\",\n \"parentPhase\": \"\",\n \"existsToday\": \"\"\n}\n","validation_input":"{\"Element\": \"test\", \"objectName\": \"contacts\", \"Path\": \"/c\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\"}\n{\"Element\": \"test\", \"objectName\": \"other\", \"Path\": \"/o\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\"}","validation_output":"{\n \"Element\": \"test\",\n \"objectName\": \"contacts\",\n \"Path\": \"/c\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"Y\",\n \"Gap\": \"\"\n}\n{\n \"Element\": \"test\",\n \"objectName\": \"other\",\n \"Path\": \"/o\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"\",\n \"Gap\": \"\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48878003/jq-edit-file-in-place-after-using-jq-select","question_title":"JQ edit file in place after using JQ Select","question_owner":"Goldfish","answer_owner":"peak","answer_id":48878072,"question_score":6,"reviewed":true} {"id":"so-48878003-p1","request":"Iterate through a JSON stream; if an object's 'objectName' is 'contacts', assign 'Y' to its 'IBM' field, otherwise pass the object through unchanged.","command":"jq 'if .objectName == \"contacts\" then .IBM = \"Y\" else . end'","input_text":"{\"Element\": \"acton\", \"objectName\": \"contacts\", \"Path\": \"/contacts\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\", \"clientPhase\": \"\", \"parentPhase\": \"\", \"existsToday\": \"\"}\n{\"Element\": \"acton\", \"objectName\": \"optouts\", \"Path\": \"/optouts\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Dependency\": \"\", \"Gap\": \"\", \"clientPhase\": \"\", \"parentPhase\": \"\", \"existsToday\": \"\"}","expected_output":"{\n \"Element\": \"acton\",\n \"objectName\": \"contacts\",\n \"Path\": \"/contacts\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"Y\",\n \"Gap\": \"\",\n \"clientPhase\": \"\",\n \"parentPhase\": \"\",\n \"existsToday\": \"\"\n}\n{\n \"Element\": \"acton\",\n \"objectName\": \"optouts\",\n \"Path\": \"/optouts\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"\",\n \"Dependency\": \"\",\n \"Gap\": \"\",\n \"clientPhase\": \"\",\n \"parentPhase\": \"\",\n \"existsToday\": \"\"\n}\n","validation_input":"{\"Element\": \"test\", \"objectName\": \"contacts\", \"Path\": \"/c\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\"}\n{\"Element\": \"test\", \"objectName\": \"other\", \"Path\": \"/o\", \"Scenario\": \"\", \"serviceLevel\": \"\", \"IBM\": \"\", \"Gap\": \"\"}","validation_output":"{\n \"Element\": \"test\",\n \"objectName\": \"contacts\",\n \"Path\": \"/c\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"Y\",\n \"Gap\": \"\"\n}\n{\n \"Element\": \"test\",\n \"objectName\": \"other\",\n \"Path\": \"/o\",\n \"Scenario\": \"\",\n \"serviceLevel\": \"\",\n \"IBM\": \"\",\n \"Gap\": \"\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48878003/jq-edit-file-in-place-after-using-jq-select","question_title":"JQ edit file in place after using JQ Select","question_owner":"Goldfish","answer_owner":"peak","answer_id":48878072,"question_score":6,"reviewed":true,"paraphrase_of":"so-48878003","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48983196","request":"Append a duplicate of the last element in the 'features' array to the end of that array within a JSON object.","command":"jq '.features |= . + [.[-1]]'","input_text":"{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", \"properties\": {\"LINE\": \"RED\", \"STATION\": \"Harvard\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [-71.11, 42.37]}}, {\"type\": \"Feature\", \"properties\": {\"LINE\": \"RED\", \"STATION\": \"Ashmont\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [-71.06, 42.28]}}]}","expected_output":"{\n \"type\": \"FeatureCollection\",\n \"features\": [\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Harvard\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.11,\n 42.37\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Ashmont\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.06,\n 42.28\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Ashmont\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.06,\n 42.28\n ]\n }\n }\n ]\n}\n","validation_input":"{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", \"properties\": {\"LINE\": \"BLUE\", \"STATION\": \"Park\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [1.0, 2.0]}}, {\"type\": \"Feature\", \"properties\": {\"LINE\": \"GREEN\", \"STATION\": \"Central\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [3.0, 4.0]}}]}","validation_output":"{\n \"type\": \"FeatureCollection\",\n \"features\": [\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"BLUE\",\n \"STATION\": \"Park\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 1,\n 2\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"GREEN\",\n \"STATION\": \"Central\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 3,\n 4\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"GREEN\",\n \"STATION\": \"Central\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 3,\n 4\n ]\n }\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48983196/how-can-i-duplicate-an-existing-object-within-a-json-array-using-jq","question_title":"How can I duplicate an existing object within a JSON array using jq?","question_owner":"m.brocks","answer_owner":"RomanPerekhrest","answer_id":48984894,"question_score":5,"reviewed":true} {"id":"so-48983196-p1","request":"Within a JSON object, duplicate the last element of the 'features' array and append it to the end of that same array.","command":"jq '.features |= . + [.[-1]]'","input_text":"{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", \"properties\": {\"LINE\": \"RED\", \"STATION\": \"Harvard\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [-71.11, 42.37]}}, {\"type\": \"Feature\", \"properties\": {\"LINE\": \"RED\", \"STATION\": \"Ashmont\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [-71.06, 42.28]}}]}","expected_output":"{\n \"type\": \"FeatureCollection\",\n \"features\": [\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Harvard\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.11,\n 42.37\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Ashmont\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.06,\n 42.28\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"RED\",\n \"STATION\": \"Ashmont\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n -71.06,\n 42.28\n ]\n }\n }\n ]\n}\n","validation_input":"{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", \"properties\": {\"LINE\": \"BLUE\", \"STATION\": \"Park\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [1.0, 2.0]}}, {\"type\": \"Feature\", \"properties\": {\"LINE\": \"GREEN\", \"STATION\": \"Central\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [3.0, 4.0]}}]}","validation_output":"{\n \"type\": \"FeatureCollection\",\n \"features\": [\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"BLUE\",\n \"STATION\": \"Park\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 1,\n 2\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"GREEN\",\n \"STATION\": \"Central\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 3,\n 4\n ]\n }\n },\n {\n \"type\": \"Feature\",\n \"properties\": {\n \"LINE\": \"GREEN\",\n \"STATION\": \"Central\"\n },\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 3,\n 4\n ]\n }\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48983196/how-can-i-duplicate-an-existing-object-within-a-json-array-using-jq","question_title":"How can I duplicate an existing object within a JSON array using jq?","question_owner":"m.brocks","answer_owner":"RomanPerekhrest","answer_id":48984894,"question_score":5,"reviewed":true,"paraphrase_of":"so-48983196","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-48997962","request":"Filter the 'BackupCfg' array to keep only objects where 'type' is 'filesystem', preserving the surrounding structure.","command":"jq '.BackupCfg |= map(select(.type == \"filesystem\"))'","input_text":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repository\": \"trunk\",\n \"url\": \"test.example.com\",\n \"port\": \"394\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"Paths\": [\n \"/etc\",\n \"/home\"\n ],\n \"Cron\": \"33 0 * * *\"\n }\n ]\n },\n {\n \"type\": \"database\",\n \"repository\": \"trunk-db\",\n \"url\": \"test.example.com\",\n \"port\": \"399\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"db_type\": \"mysql\"\n }\n ]\n }\n ]\n}","expected_output":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repository\": \"trunk\",\n \"url\": \"test.example.com\",\n \"port\": \"394\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"Paths\": [\n \"/etc\",\n \"/home\"\n ],\n \"Cron\": \"33 0 * * *\"\n }\n ]\n }\n ]\n}\n","validation_input":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repo\": \"r1\"\n },\n {\n \"type\": \"cloud\",\n \"repo\": \"r2\"\n },\n {\n \"type\": \"filesystem\",\n \"repo\": \"r3\"\n }\n ]\n}","validation_output":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repo\": \"r1\"\n },\n {\n \"type\": \"filesystem\",\n \"repo\": \"r3\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48997962/jq-json-filter-and-keep-original-structure","question_title":"jq json filter and keep original structure","question_owner":"Alessandro Perucchi","answer_owner":"RomanPerekhrest","answer_id":48998014,"question_score":6,"reviewed":true} {"id":"so-48997962-p1","request":"Filter the 'BackupCfg' array to retain only entries where 'type' equals 'filesystem', maintaining the rest of the JSON structure.","command":"jq '.BackupCfg |= map(select(.type == \"filesystem\"))'","input_text":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repository\": \"trunk\",\n \"url\": \"test.example.com\",\n \"port\": \"394\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"Paths\": [\n \"/etc\",\n \"/home\"\n ],\n \"Cron\": \"33 0 * * *\"\n }\n ]\n },\n {\n \"type\": \"database\",\n \"repository\": \"trunk-db\",\n \"url\": \"test.example.com\",\n \"port\": \"399\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"db_type\": \"mysql\"\n }\n ]\n }\n ]\n}","expected_output":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repository\": \"trunk\",\n \"url\": \"test.example.com\",\n \"port\": \"394\",\n \"cfg\": [\n {\n \"Default\": \"true\",\n \"ID\": \"trunk00\",\n \"Paths\": [\n \"/etc\",\n \"/home\"\n ],\n \"Cron\": \"33 0 * * *\"\n }\n ]\n }\n ]\n}\n","validation_input":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repo\": \"r1\"\n },\n {\n \"type\": \"cloud\",\n \"repo\": \"r2\"\n },\n {\n \"type\": \"filesystem\",\n \"repo\": \"r3\"\n }\n ]\n}","validation_output":"{\n \"BackupCfg\": [\n {\n \"type\": \"filesystem\",\n \"repo\": \"r1\"\n },\n {\n \"type\": \"filesystem\",\n \"repo\": \"r3\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48997962/jq-json-filter-and-keep-original-structure","question_title":"jq json filter and keep original structure","question_owner":"Alessandro Perucchi","answer_owner":"RomanPerekhrest","answer_id":48998014,"question_score":6,"reviewed":true,"paraphrase_of":"so-48997962","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-49105880","request":"Filter an array of objects to keep only those where the 'finalStatus' field is not null.","command":"jq '[.[] | select(.finalStatus != null)]'","input_text":"[\n {\n \"_type\": \"http\",\n \"uri\": \"/rest/eFulfillment/V1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"connecte-esb-bat.dhl.com\",\n \"remoteAddr\": \"165.72.94.127\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"443\",\n \"localPort\": \"52842\",\n \"sslsubject\": \"/C=DE/ST=Nordrhein-Westfalen/L=Bonn/O=Deutsche Post AG/OU=ITSC/CN=connecte-esb-bat.dhl.com\",\n \"leg\": 1,\n \"timestamp\": 1520235200649,\n \"duration\": 1099,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": null\n },\n {\n \"_type\": \"http\",\n \"uri\": \"/efulfillment/v1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"165.72.87.12\",\n \"remoteAddr\": \"165.72.87.12\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"51946\",\n \"localPort\": \"6443\",\n \"sslsubject\": null,\n \"leg\": 0,\n \"timestamp\": 1520235200642,\n \"duration\": 1107,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": \"Pass\"\n }\n]","expected_output":"[\n {\n \"_type\": \"http\",\n \"uri\": \"/efulfillment/v1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"165.72.87.12\",\n \"remoteAddr\": \"165.72.87.12\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"51946\",\n \"localPort\": \"6443\",\n \"sslsubject\": null,\n \"leg\": 0,\n \"timestamp\": 1520235200642,\n \"duration\": 1107,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": \"Pass\"\n }\n]\n","validation_input":"[\n {\n \"id\": 1,\n \"name\": \"Item A\",\n \"finalStatus\": null\n },\n {\n \"id\": 2,\n \"name\": \"Item B\",\n \"finalStatus\": \"Completed\"\n },\n {\n \"id\": 3,\n \"name\": \"Item C\",\n \"finalStatus\": \"Failed\"\n },\n {\n \"id\": 4,\n \"name\": \"Item D\",\n \"finalStatus\": null\n }\n]","validation_output":"[\n {\n \"id\": 2,\n \"name\": \"Item B\",\n \"finalStatus\": \"Completed\"\n },\n {\n \"id\": 3,\n \"name\": \"Item C\",\n \"finalStatus\": \"Failed\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49105880/jq-how-to-output-document-if-a-value-is-not-null","question_title":"jq - how to output document if a value is not null?","question_owner":"Reddy SK","answer_owner":"Bob Dust","answer_id":49106090,"question_score":5,"reviewed":true} {"id":"so-49105880-p1","request":"Select only those objects from an array where the 'finalStatus' field is not null.","command":"jq '[.[] | select(.finalStatus != null)]'","input_text":"[\n {\n \"_type\": \"http\",\n \"uri\": \"/rest/eFulfillment/V1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"connecte-esb-bat.dhl.com\",\n \"remoteAddr\": \"165.72.94.127\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"443\",\n \"localPort\": \"52842\",\n \"sslsubject\": \"/C=DE/ST=Nordrhein-Westfalen/L=Bonn/O=Deutsche Post AG/OU=ITSC/CN=connecte-esb-bat.dhl.com\",\n \"leg\": 1,\n \"timestamp\": 1520235200649,\n \"duration\": 1099,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": null\n },\n {\n \"_type\": \"http\",\n \"uri\": \"/efulfillment/v1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"165.72.87.12\",\n \"remoteAddr\": \"165.72.87.12\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"51946\",\n \"localPort\": \"6443\",\n \"sslsubject\": null,\n \"leg\": 0,\n \"timestamp\": 1520235200642,\n \"duration\": 1107,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": \"Pass\"\n }\n]","expected_output":"[\n {\n \"_type\": \"http\",\n \"uri\": \"/efulfillment/v1/stock/5117855/OHK30\",\n \"status\": 200,\n \"statustext\": \"OK\",\n \"method\": \"GET\",\n \"vhost\": null,\n \"wafStatus\": 0,\n \"bytesSent\": 0,\n \"bytesReceived\": 0,\n \"remoteName\": \"165.72.87.12\",\n \"remoteAddr\": \"165.72.87.12\",\n \"localAddr\": \"165.72.1.236\",\n \"remotePort\": \"51946\",\n \"localPort\": \"6443\",\n \"sslsubject\": null,\n \"leg\": 0,\n \"timestamp\": 1520235200642,\n \"duration\": 1107,\n \"correlationId\": \"c0f29c5a3e484ba5419878db\",\n \"serviceName\": \"PeP e-Fulfillment API\",\n \"subject\": \"d006366e-3b9e-415f-baff-cc1eec24898a\",\n \"operation\": \"Get Available Stock\",\n \"type\": \"http\",\n \"finalStatus\": \"Pass\"\n }\n]\n","validation_input":"[\n {\n \"id\": 1,\n \"name\": \"Item A\",\n \"finalStatus\": null\n },\n {\n \"id\": 2,\n \"name\": \"Item B\",\n \"finalStatus\": \"Completed\"\n },\n {\n \"id\": 3,\n \"name\": \"Item C\",\n \"finalStatus\": \"Failed\"\n },\n {\n \"id\": 4,\n \"name\": \"Item D\",\n \"finalStatus\": null\n }\n]","validation_output":"[\n {\n \"id\": 2,\n \"name\": \"Item B\",\n \"finalStatus\": \"Completed\"\n },\n {\n \"id\": 3,\n \"name\": \"Item C\",\n \"finalStatus\": \"Failed\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49105880/jq-how-to-output-document-if-a-value-is-not-null","question_title":"jq - how to output document if a value is not null?","question_owner":"Reddy SK","answer_owner":"Bob Dust","answer_id":49106090,"question_score":5,"reviewed":true,"paraphrase_of":"so-49105880","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-49127676","request":"Remove the 'age' key from each object in a JSON array.","command":"jq 'map(del(.age))'","input_text":"[{\"id\": 1, \"name\": \"Arthur\", \"age\": \"21\"}, {\"id\": 2, \"name\": \"Richard\", \"age\": \"32\"}]","expected_output":"[\n {\n \"id\": 1,\n \"name\": \"Arthur\"\n },\n {\n \"id\": 2,\n \"name\": \"Richard\"\n }\n]\n","validation_input":"[{\"id\": 3, \"name\": \"Bob\", \"age\": \"40\"}, {\"id\": 4, \"name\": \"Alice\", \"age\": \"25\"}]","validation_output":"[\n {\n \"id\": 3,\n \"name\": \"Bob\"\n },\n {\n \"id\": 4,\n \"name\": \"Alice\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49127676/delete-key-present-inside-objects-array-via-jq","question_title":"Delete key present inside objects array via jq","question_owner":"shadyabhi","answer_owner":"Inian","answer_id":49127869,"question_score":5,"reviewed":true} {"id":"so-49127676-p1","request":"Delete the 'age' property from every object contained in a JSON array.","command":"jq 'map(del(.age))'","input_text":"[{\"id\": 1, \"name\": \"Arthur\", \"age\": \"21\"}, {\"id\": 2, \"name\": \"Richard\", \"age\": \"32\"}]","expected_output":"[\n {\n \"id\": 1,\n \"name\": \"Arthur\"\n },\n {\n \"id\": 2,\n \"name\": \"Richard\"\n }\n]\n","validation_input":"[{\"id\": 3, \"name\": \"Bob\", \"age\": \"40\"}, {\"id\": 4, \"name\": \"Alice\", \"age\": \"25\"}]","validation_output":"[\n {\n \"id\": 3,\n \"name\": \"Bob\"\n },\n {\n \"id\": 4,\n \"name\": \"Alice\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49127676/delete-key-present-inside-objects-array-via-jq","question_title":"Delete key present inside objects array via jq","question_owner":"shadyabhi","answer_owner":"Inian","answer_id":49127869,"question_score":5,"reviewed":true,"paraphrase_of":"so-49127676","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-49551805","request":"Remove the version suffix (starting with a hyphen followed by a number) from the string values in the input JSON object.","command":"jq 'to_entries | map(.value |= sub(\" *- *[0-9]+\\\\.[0-9]+.*$\"; \"\")) | from_entries'","input_text":"{\n \"service1\": \"countries-sapi-1.0\",\n \"service2\": \"inventory-list-api-1.0-snapshot\"\n}","expected_output":"{\n \"service1\": \"countries-sapi\",\n \"service2\": \"inventory-list-api\"\n}\n","validation_input":"{\n \"appA\": \"my-app-v2-2.1.0\",\n \"appB\": \"backend-core-1.5.3-beta\"\n}","validation_output":"{\n \"appA\": \"my-app-v2\",\n \"appB\": \"backend-core\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49551805/jq-split-string-by-a-pattern","question_title":"jq split string by a pattern","question_owner":"Naveen K Reddy","answer_owner":"peak","answer_id":49556889,"question_score":8,"reviewed":true} {"id":"so-49551805-p1","request":"Strip version suffixes—defined as a hyphen followed by digits—from all string values in the input JSON object.","command":"jq 'to_entries | map(.value |= sub(\" *- *[0-9]+\\\\.[0-9]+.*$\"; \"\")) | from_entries'","input_text":"{\n \"service1\": \"countries-sapi-1.0\",\n \"service2\": \"inventory-list-api-1.0-snapshot\"\n}","expected_output":"{\n \"service1\": \"countries-sapi\",\n \"service2\": \"inventory-list-api\"\n}\n","validation_input":"{\n \"appA\": \"my-app-v2-2.1.0\",\n \"appB\": \"backend-core-1.5.3-beta\"\n}","validation_output":"{\n \"appA\": \"my-app-v2\",\n \"appB\": \"backend-core\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49551805/jq-split-string-by-a-pattern","question_title":"jq split string by a pattern","question_owner":"Naveen K Reddy","answer_owner":"peak","answer_id":49556889,"question_score":8,"reviewed":true,"paraphrase_of":"so-49551805","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-49556242","request":"Output the keys of the top-level JSON object as raw strings, one per line.","command":"jq -r 'keys[]'","input_text":"{\n \"201110131738QP27N\": {\n \"parent\": 17,\n \"name\": \"CentralServer\",\n \"status\": \"Active\",\n \"count\": 6\n },\n \"201803271459ICV69\": {\n \"name\": \"subaccount1\",\n \"status\": \"Active\",\n \"count\": 1\n },\n \"2018032715008ZM2G\": {\n \"name\": \"subaccount2\",\n \"status\": \"Active\",\n \"count\": 1\n },\n \"201803281536PSKR4\": {\n \"name\": \"Este e um teste\",\n \"status\": \"Active\"\n }\n}","expected_output":"201110131738QP27N\n201803271459ICV69\n2018032715008ZM2G\n201803281536PSKR4\n","validation_input":"{\n \"keyA\": {\n \"val\": 1\n },\n \"keyB\": {\n \"val\": 2\n }\n}","validation_output":"keyA\nkeyB\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49556242/get-data-from-a-json-output-using-jq","question_title":"Get data from a JSON output using 'jq'","question_owner":"RafaelBrianeziDaSilva","answer_owner":"Inian","answer_id":49556547,"question_score":6,"reviewed":true} {"id":"so-49556242-p1","request":"Extract the top-level keys from the JSON object and print each as a raw string on a new line.","command":"jq -r 'keys[]'","input_text":"{\n \"201110131738QP27N\": {\n \"parent\": 17,\n \"name\": \"CentralServer\",\n \"status\": \"Active\",\n \"count\": 6\n },\n \"201803271459ICV69\": {\n \"name\": \"subaccount1\",\n \"status\": \"Active\",\n \"count\": 1\n },\n \"2018032715008ZM2G\": {\n \"name\": \"subaccount2\",\n \"status\": \"Active\",\n \"count\": 1\n },\n \"201803281536PSKR4\": {\n \"name\": \"Este e um teste\",\n \"status\": \"Active\"\n }\n}","expected_output":"201110131738QP27N\n201803271459ICV69\n2018032715008ZM2G\n201803281536PSKR4\n","validation_input":"{\n \"keyA\": {\n \"val\": 1\n },\n \"keyB\": {\n \"val\": 2\n }\n}","validation_output":"keyA\nkeyB\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49556242/get-data-from-a-json-output-using-jq","question_title":"Get data from a JSON output using 'jq'","question_owner":"RafaelBrianeziDaSilva","answer_owner":"Inian","answer_id":49556547,"question_score":6,"reviewed":true,"paraphrase_of":"so-49556242","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-50354926","request":"Merge two arrays of objects by the 'Key' field, keeping the value from the second array if a key exists in both. The input is a single JSON array containing exactly two sub-arrays: the first array and the second array.","command":"jq -c '.[0] + .[1] | group_by(.Key) | map(.[-1])'","input_text":"[\n [\n {\"Key\": \"A B\", \"Value\": \"1 2\"},\n {\"Key\": \"C D\", \"Value\": \"3 4\"}\n ],\n [\n {\"Key\": \"C D\", \"Value\": \"updated\"},\n {\"Key\": \"E F\", \"Value\": \"5 6\"}\n ]\n]","expected_output":"[{\"Key\":\"A B\",\"Value\":\"1 2\"},{\"Key\":\"C D\",\"Value\":\"updated\"},{\"Key\":\"E F\",\"Value\":\"5 6\"}]\n","validation_input":"[\n [\n {\"Key\": \"X\", \"Value\": \"1\"},\n {\"Key\": \"Y\", \"Value\": \"2\"},\n {\"Key\": \"Z\", \"Value\": \"3\"}\n ],\n [\n {\"Key\": \"Y\", \"Value\": \"2_new\"},\n {\"Key\": \"W\", \"Value\": \"4\"}\n ]\n]","validation_output":"[{\"Key\":\"W\",\"Value\":\"4\"},{\"Key\":\"X\",\"Value\":\"1\"},{\"Key\":\"Y\",\"Value\":\"2_new\"},{\"Key\":\"Z\",\"Value\":\"3\"}]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50354926/jq-merge-two-arrays","question_title":"JQ - Merge two arrays","question_owner":"Nam Nguyen","answer_owner":"RomanPerekhrest","answer_id":50355185,"question_score":10,"reviewed":true} {"id":"so-50354926-p1","request":"Perform a left-join merge on two object arrays using the 'Key' field, prioritizing values from the second array when duplicates exist. The input is a JSON array containing exactly these two sub-arrays.","command":"jq -c '.[0] + .[1] | group_by(.Key) | map(.[-1])'","input_text":"[\n [\n {\"Key\": \"A B\", \"Value\": \"1 2\"},\n {\"Key\": \"C D\", \"Value\": \"3 4\"}\n ],\n [\n {\"Key\": \"C D\", \"Value\": \"updated\"},\n {\"Key\": \"E F\", \"Value\": \"5 6\"}\n ]\n]","expected_output":"[{\"Key\":\"A B\",\"Value\":\"1 2\"},{\"Key\":\"C D\",\"Value\":\"updated\"},{\"Key\":\"E F\",\"Value\":\"5 6\"}]\n","validation_input":"[\n [\n {\"Key\": \"X\", \"Value\": \"1\"},\n {\"Key\": \"Y\", \"Value\": \"2\"},\n {\"Key\": \"Z\", \"Value\": \"3\"}\n ],\n [\n {\"Key\": \"Y\", \"Value\": \"2_new\"},\n {\"Key\": \"W\", \"Value\": \"4\"}\n ]\n]","validation_output":"[{\"Key\":\"W\",\"Value\":\"4\"},{\"Key\":\"X\",\"Value\":\"1\"},{\"Key\":\"Y\",\"Value\":\"2_new\"},{\"Key\":\"Z\",\"Value\":\"3\"}]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50354926/jq-merge-two-arrays","question_title":"JQ - Merge two arrays","question_owner":"Nam Nguyen","answer_owner":"RomanPerekhrest","answer_id":50355185,"question_score":10,"reviewed":true,"paraphrase_of":"so-50354926","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-50864894","request":"Filter the keys in the 'timers' object to keep only those containing the substring 'KeywordA', preserving their values.","command":"jq '.timers | with_entries(select(.key | contains(\"KeywordA\")))'","input_text":"{\"timers\": {\"timerWithAKeywordAPlusBlah\": {\"count\": 1}, \"timerWithB\": {\"count\": 2}, \"timerWithAKeywordAPlusBlahBlah\": {\"count\": 2385}}}","expected_output":"{\n \"timerWithAKeywordAPlusBlah\": {\n \"count\": 1\n },\n \"timerWithAKeywordAPlusBlahBlah\": {\n \"count\": 2385\n }\n}\n","validation_input":"{\"timers\": {\"KeyA_1\": {\"val\": 10}, \"Other\": {\"val\": 20}, \"MyKeyA\": {\"val\": 30}}}","validation_output":"{}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50864894/how-to-filter-keys-by-name-then-access-nested-object-using-jq","question_title":"How to filter keys by name, then access nested object using jq","question_owner":"lazy_tester","answer_owner":"peak","answer_id":50865502,"question_score":10,"reviewed":true} {"id":"so-50864894-p1","request":"From the 'timers' object, retain only the key-value pairs where the key includes the substring 'KeywordA'.","command":"jq '.timers | with_entries(select(.key | contains(\"KeywordA\")))'","input_text":"{\"timers\": {\"timerWithAKeywordAPlusBlah\": {\"count\": 1}, \"timerWithB\": {\"count\": 2}, \"timerWithAKeywordAPlusBlahBlah\": {\"count\": 2385}}}","expected_output":"{\n \"timerWithAKeywordAPlusBlah\": {\n \"count\": 1\n },\n \"timerWithAKeywordAPlusBlahBlah\": {\n \"count\": 2385\n }\n}\n","validation_input":"{\"timers\": {\"KeyA_1\": {\"val\": 10}, \"Other\": {\"val\": 20}, \"MyKeyA\": {\"val\": 30}}}","validation_output":"{}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50864894/how-to-filter-keys-by-name-then-access-nested-object-using-jq","question_title":"How to filter keys by name, then access nested object using jq","question_owner":"lazy_tester","answer_owner":"peak","answer_id":50865502,"question_score":10,"reviewed":true,"paraphrase_of":"so-50864894","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51477085","request":"Flatten the nested instances array within alerts, merging instance fields with alert fields while preserving top-level site metadata, and output the result as a single JSON object.","command":"jq '{\"@name\": .site.\"@name\", \"@ssl\": .site.\"@ssl\", \"alerts\": [.site.alerts[] as $in | $in.instances[] as $h | $in | del(.instances) as $in2 | $h * $in2]}'","input_text":"{\n \"@version\": \"2.7.0\",\n \"site\": {\n \"@name\": \"http://api:9999\",\n \"@ssl\": \"false\",\n \"alerts\": [\n {\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server<\\/p>\",\n \"instances\": [\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"DxyPP_YQ6qdWA_Kw_ZLgYilIkXCz93Xs1CeJPvg\"\n },\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"eyJuYmYiOjE121lMWF1siSG9tZUFwcCJdfQ\"\n }\n ],\n \"count\": \"37\"\n }\n ]\n }\n}","expected_output":"{\n \"@name\": \"http://api:9999\",\n \"@ssl\": \"false\",\n \"alerts\": [\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"DxyPP_YQ6qdWA_Kw_ZLgYilIkXCz93Xs1CeJPvg\",\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server

\",\n \"count\": \"37\"\n },\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"eyJuYmYiOjE121lMWF1siSG9tZUFwcCJdfQ\",\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server

\",\n \"count\": \"37\"\n }\n ]\n}\n","validation_input":"{\n \"@version\": \"3.0.0\",\n \"site\": {\n \"@name\": \"http://test:8080\",\n \"@ssl\": \"true\",\n \"alerts\": [\n {\n \"pluginid\": \"20001\",\n \"desc\": \"Test description\",\n \"instances\": [\n {\n \"uri\": \"http://test:8080/v1\",\n \"method\": \"GET\",\n \"evidence\": \"ABC123\"\n }\n ],\n \"count\": \"1\"\n }\n ]\n }\n}","validation_output":"{\n \"@name\": \"http://test:8080\",\n \"@ssl\": \"true\",\n \"alerts\": [\n {\n \"uri\": \"http://test:8080/v1\",\n \"method\": \"GET\",\n \"evidence\": \"ABC123\",\n \"pluginid\": \"20001\",\n \"desc\": \"Test description\",\n \"count\": \"1\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51477085/flatten-nested-json-array-with-jq","question_title":"Flatten nested JSON array with JQ","question_owner":"Omer Levi Hevroni","answer_owner":"Inian","answer_id":51483770,"question_score":8,"reviewed":true} {"id":"so-51477085-p1","request":"Flatten the nested 'instances' array within 'alerts' by merging instance properties with alert properties, while keeping top-level site metadata intact, and return the result as a single JSON object.","command":"jq '{\"@name\": .site.\"@name\", \"@ssl\": .site.\"@ssl\", \"alerts\": [.site.alerts[] as $in | $in.instances[] as $h | $in | del(.instances) as $in2 | $h * $in2]}'","input_text":"{\n \"@version\": \"2.7.0\",\n \"site\": {\n \"@name\": \"http://api:9999\",\n \"@ssl\": \"false\",\n \"alerts\": [\n {\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server<\\/p>\",\n \"instances\": [\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"DxyPP_YQ6qdWA_Kw_ZLgYilIkXCz93Xs1CeJPvg\"\n },\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"eyJuYmYiOjE121lMWF1siSG9tZUFwcCJdfQ\"\n }\n ],\n \"count\": \"37\"\n }\n ]\n }\n}","expected_output":"{\n \"@name\": \"http://api:9999\",\n \"@ssl\": \"false\",\n \"alerts\": [\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"DxyPP_YQ6qdWA_Kw_ZLgYilIkXCz93Xs1CeJPvg\",\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server

\",\n \"count\": \"37\"\n },\n {\n \"uri\": \"http://api:9999\",\n \"method\": \"POST\",\n \"evidence\": \"eyJuYmYiOjE121lMWF1siSG9tZUFwcCJdfQ\",\n \"pluginid\": \"10094\",\n \"desc\": \"

Base64 encoded data was disclosed by the application/web server

\",\n \"count\": \"37\"\n }\n ]\n}\n","validation_input":"{\n \"@version\": \"3.0.0\",\n \"site\": {\n \"@name\": \"http://test:8080\",\n \"@ssl\": \"true\",\n \"alerts\": [\n {\n \"pluginid\": \"20001\",\n \"desc\": \"Test description\",\n \"instances\": [\n {\n \"uri\": \"http://test:8080/v1\",\n \"method\": \"GET\",\n \"evidence\": \"ABC123\"\n }\n ],\n \"count\": \"1\"\n }\n ]\n }\n}","validation_output":"{\n \"@name\": \"http://test:8080\",\n \"@ssl\": \"true\",\n \"alerts\": [\n {\n \"uri\": \"http://test:8080/v1\",\n \"method\": \"GET\",\n \"evidence\": \"ABC123\",\n \"pluginid\": \"20001\",\n \"desc\": \"Test description\",\n \"count\": \"1\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51477085/flatten-nested-json-array-with-jq","question_title":"Flatten nested JSON array with JQ","question_owner":"Omer Levi Hevroni","answer_owner":"Inian","answer_id":51483770,"question_score":8,"reviewed":true,"paraphrase_of":"so-51477085","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51491317","request":"Merge multiple JSON objects from a stream into a single object where keys are derived from the 'b' field and values from the 'd' field of the nested 'a' object in each input object.","command":"jq -s '[.[] | .a | {(.b): .d}] | add'","input_text":"{\"a\": {\"b\": \"c\", \"d\": \"e\"}}\n{\"a\": {\"b\": \"f\", \"d\": \"g\"}}","expected_output":"{\n \"c\": \"e\",\n \"f\": \"g\"\n}\n","validation_input":"{\"a\": {\"b\": \"x\", \"d\": \"y\"}}\n{\"a\": {\"b\": \"z\", \"d\": \"w\"}}","validation_output":"{\n \"x\": \"y\",\n \"z\": \"w\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51491317/jq-how-to-merge-multiple-objects-into-one","question_title":"JQ How to merge multiple objects into one","question_owner":"JdeHaan","answer_owner":"peak","answer_id":51492578,"question_score":8,"reviewed":true} {"id":"so-51491317-p1","request":"Combine multiple JSON objects from a stream into one object, mapping keys from the 'b' field and values from the 'd' field located inside the nested 'a' object of each input.","command":"jq -s '[.[] | .a | {(.b): .d}] | add'","input_text":"{\"a\": {\"b\": \"c\", \"d\": \"e\"}}\n{\"a\": {\"b\": \"f\", \"d\": \"g\"}}","expected_output":"{\n \"c\": \"e\",\n \"f\": \"g\"\n}\n","validation_input":"{\"a\": {\"b\": \"x\", \"d\": \"y\"}}\n{\"a\": {\"b\": \"z\", \"d\": \"w\"}}","validation_output":"{\n \"x\": \"y\",\n \"z\": \"w\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51491317/jq-how-to-merge-multiple-objects-into-one","question_title":"JQ How to merge multiple objects into one","question_owner":"JdeHaan","answer_owner":"peak","answer_id":51492578,"question_score":8,"reviewed":true,"paraphrase_of":"so-51491317","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51558701","request":"Enrich each object in the wireless array with its corresponding address from the address array by matching the wireless name to the interface name, using an index lookup.","command":"jq '(INDEX(.address[]; .interface)) as $dict | {name, version, wireless: (.wireless | map(. + {address: ($dict[.name]|.address) }) ) }'","input_text":"{\"name\": \"device\", \"version\": \"1.0.0\", \"address\": [{\"address\": \"10.1.2.3\", \"interface\": \"wlan1_wifi\"}, {\"address\": \"10.1.2.5\", \"interface\": \"wlan2_link\"}, {\"address\": \"10.1.2.4\", \"interface\": \"ether1\"}], \"wireless\": [{\"name\": \"wlan1_wifi\", \"type\": \"5Ghz\", \"ssid\": \"wifi\"}, {\"name\": \"wlan2_link\", \"type\": \"2Ghz\", \"ssid\": \"link\"}]}","expected_output":"{\n \"name\": \"device\",\n \"version\": \"1.0.0\",\n \"wireless\": [\n {\n \"name\": \"wlan1_wifi\",\n \"type\": \"5Ghz\",\n \"ssid\": \"wifi\",\n \"address\": \"10.1.2.3\"\n },\n {\n \"name\": \"wlan2_link\",\n \"type\": \"2Ghz\",\n \"ssid\": \"link\",\n \"address\": \"10.1.2.5\"\n }\n ]\n}\n","validation_input":"{\"name\": \"router\", \"version\": \"2.0.0\", \"address\": [{\"address\": \"192.168.1.1\", \"interface\": \"eth0\"}, {\"address\": \"192.168.1.2\", \"interface\": \"wlan0\"}], \"wireless\": [{\"name\": \"wlan0\", \"type\": \"2.4Ghz\", \"ssid\": \"home_net\"}, {\"name\": \"eth0\", \"type\": \"wired\", \"ssid\": null}]}","validation_output":"{\n \"name\": \"router\",\n \"version\": \"2.0.0\",\n \"wireless\": [\n {\n \"name\": \"wlan0\",\n \"type\": \"2.4Ghz\",\n \"ssid\": \"home_net\",\n \"address\": \"192.168.1.2\"\n },\n {\n \"name\": \"eth0\",\n \"type\": \"wired\",\n \"ssid\": null,\n \"address\": \"192.168.1.1\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51558701/jq-find-a-json-object-based-on-one-of-its-values-and-get-another-value-from-it","question_title":"jq - Find a JSON object based on one of its values and get another value from it","question_owner":"user5971350","answer_owner":"peak","answer_id":51563052,"question_score":5,"reviewed":true} {"id":"so-51558701-p1","request":"Augment each entry in the 'wireless' array with its matching address from the 'address' array by aligning the wireless name with the interface name via index lookup.","command":"jq '(INDEX(.address[]; .interface)) as $dict | {name, version, wireless: (.wireless | map(. + {address: ($dict[.name]|.address) }) ) }'","input_text":"{\"name\": \"device\", \"version\": \"1.0.0\", \"address\": [{\"address\": \"10.1.2.3\", \"interface\": \"wlan1_wifi\"}, {\"address\": \"10.1.2.5\", \"interface\": \"wlan2_link\"}, {\"address\": \"10.1.2.4\", \"interface\": \"ether1\"}], \"wireless\": [{\"name\": \"wlan1_wifi\", \"type\": \"5Ghz\", \"ssid\": \"wifi\"}, {\"name\": \"wlan2_link\", \"type\": \"2Ghz\", \"ssid\": \"link\"}]}","expected_output":"{\n \"name\": \"device\",\n \"version\": \"1.0.0\",\n \"wireless\": [\n {\n \"name\": \"wlan1_wifi\",\n \"type\": \"5Ghz\",\n \"ssid\": \"wifi\",\n \"address\": \"10.1.2.3\"\n },\n {\n \"name\": \"wlan2_link\",\n \"type\": \"2Ghz\",\n \"ssid\": \"link\",\n \"address\": \"10.1.2.5\"\n }\n ]\n}\n","validation_input":"{\"name\": \"router\", \"version\": \"2.0.0\", \"address\": [{\"address\": \"192.168.1.1\", \"interface\": \"eth0\"}, {\"address\": \"192.168.1.2\", \"interface\": \"wlan0\"}], \"wireless\": [{\"name\": \"wlan0\", \"type\": \"2.4Ghz\", \"ssid\": \"home_net\"}, {\"name\": \"eth0\", \"type\": \"wired\", \"ssid\": null}]}","validation_output":"{\n \"name\": \"router\",\n \"version\": \"2.0.0\",\n \"wireless\": [\n {\n \"name\": \"wlan0\",\n \"type\": \"2.4Ghz\",\n \"ssid\": \"home_net\",\n \"address\": \"192.168.1.2\"\n },\n {\n \"name\": \"eth0\",\n \"type\": \"wired\",\n \"ssid\": null,\n \"address\": \"192.168.1.1\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51558701/jq-find-a-json-object-based-on-one-of-its-values-and-get-another-value-from-it","question_title":"jq - Find a JSON object based on one of its values and get another value from it","question_owner":"user5971350","answer_owner":"peak","answer_id":51563052,"question_score":5,"reviewed":true,"paraphrase_of":"so-51558701","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51718102","request":"Filter the 'LoadBalancers' array in the input object to return only the object where the DNSName matches 'MY-LB2-9876556789.us-west-2.elb.amazonaws.com' in a case-insensitive manner.","command":"jq '.LoadBalancers[] | select(.DNSName | ascii_upcase == \"MY-LB2-9876556789.US-WEST-2.ELB.AMAZONAWS.COM\")'","input_text":"{\"LoadBalancers\":[{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-abcdabcd\",\"LoadBalancerArn\":\"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB1/a00000000000000a\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"MY-LB1-123454321.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[\"sg-00100100\",\"sg-01001000\",\"sg-10010001\"],\"LoadBalancerName\":\"MY-LB1\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internet-facing\",\"Type\":\"application\",\"CanonicalHostedZoneId\":\"ZZZZZZZZZZZZZ\",\"AvailabilityZones\":[{\"SubnetId\":\"subnet-17171717\",\"ZoneName\":\"us-west-2a\"},{\"SubnetId\":\"subnet-27272727\",\"ZoneName\":\"us-west-2c\"},{\"SubnetId\":\"subnet-37373737\",\"ZoneName\":\"us-west-2b\"}]},{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-abcdabcd\",\"LoadBalancerArn\":\"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"MY-LB2-9876556789.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[\"sg-88818881\"],\"LoadBalancerName\":\"MY-LB2\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internet-facing\",\"Type\":\"application\",\"CanonicalHostedZoneId\":\"ZZZZZZZZZZZZZ\",\"AvailabilityZones\":[{\"SubnetId\":\"subnet-54545454\",\"ZoneName\":\"us-west-2a\"},{\"SubnetId\":\"subnet-64646464\",\"ZoneName\":\"us-west-2c\"},{\"SubnetId\":\"subnet-74747474\",\"ZoneName\":\"us-west-2b\"}]}]}","expected_output":"{\n \"IpAddressType\": \"ipv4\",\n \"VpcId\": \"vpc-abcdabcd\",\n \"LoadBalancerArn\": \"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b\",\n \"State\": {\n \"Code\": \"active\"\n },\n \"DNSName\": \"MY-LB2-9876556789.us-west-2.elb.amazonaws.com\",\n \"SecurityGroups\": [\n \"sg-88818881\"\n ],\n \"LoadBalancerName\": \"MY-LB2\",\n \"CreatedTime\": \"2018-01-01T00:00:00.000Z\",\n \"Scheme\": \"internet-facing\",\n \"Type\": \"application\",\n \"CanonicalHostedZoneId\": \"ZZZZZZZZZZZZZ\",\n \"AvailabilityZones\": [\n {\n \"SubnetId\": \"subnet-54545454\",\n \"ZoneName\": \"us-west-2a\"\n },\n {\n \"SubnetId\": \"subnet-64646464\",\n \"ZoneName\": \"us-west-2c\"\n },\n {\n \"SubnetId\": \"subnet-74747474\",\n \"ZoneName\": \"us-west-2b\"\n }\n ]\n}\n","validation_input":"{\"LoadBalancers\":[{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-test\",\"LoadBalancerArn\":\"arn:aws:test\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"my-lb2-9876556789.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[],\"LoadBalancerName\":\"MY-LB2\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internal\",\"Type\":\"network\",\"CanonicalHostedZoneId\":\"YYYYYYYYYYY\",\"AvailabilityZones\":[]}]}","validation_output":"{\n \"IpAddressType\": \"ipv4\",\n \"VpcId\": \"vpc-test\",\n \"LoadBalancerArn\": \"arn:aws:test\",\n \"State\": {\n \"Code\": \"active\"\n },\n \"DNSName\": \"my-lb2-9876556789.us-west-2.elb.amazonaws.com\",\n \"SecurityGroups\": [],\n \"LoadBalancerName\": \"MY-LB2\",\n \"CreatedTime\": \"2018-01-01T00:00:00.000Z\",\n \"Scheme\": \"internal\",\n \"Type\": \"network\",\n \"CanonicalHostedZoneId\": \"YYYYYYYYYYY\",\n \"AvailabilityZones\": []\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51718102/filter-json-via-bash-case-insensitive","question_title":"filter json via bash - case insensitive","question_owner":"hey","answer_owner":"peak","answer_id":51718532,"question_score":5,"reviewed":true} {"id":"so-51718102-p1","request":"Filter the 'LoadBalancers' array to return only the entry with a DNSName matching 'MY-LB2-9876556789.us-west-2.elb.amazonaws.com', ignoring case.","command":"jq '.LoadBalancers[] | select(.DNSName | ascii_upcase == \"MY-LB2-9876556789.US-WEST-2.ELB.AMAZONAWS.COM\")'","input_text":"{\"LoadBalancers\":[{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-abcdabcd\",\"LoadBalancerArn\":\"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB1/a00000000000000a\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"MY-LB1-123454321.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[\"sg-00100100\",\"sg-01001000\",\"sg-10010001\"],\"LoadBalancerName\":\"MY-LB1\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internet-facing\",\"Type\":\"application\",\"CanonicalHostedZoneId\":\"ZZZZZZZZZZZZZ\",\"AvailabilityZones\":[{\"SubnetId\":\"subnet-17171717\",\"ZoneName\":\"us-west-2a\"},{\"SubnetId\":\"subnet-27272727\",\"ZoneName\":\"us-west-2c\"},{\"SubnetId\":\"subnet-37373737\",\"ZoneName\":\"us-west-2b\"}]},{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-abcdabcd\",\"LoadBalancerArn\":\"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"MY-LB2-9876556789.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[\"sg-88818881\"],\"LoadBalancerName\":\"MY-LB2\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internet-facing\",\"Type\":\"application\",\"CanonicalHostedZoneId\":\"ZZZZZZZZZZZZZ\",\"AvailabilityZones\":[{\"SubnetId\":\"subnet-54545454\",\"ZoneName\":\"us-west-2a\"},{\"SubnetId\":\"subnet-64646464\",\"ZoneName\":\"us-west-2c\"},{\"SubnetId\":\"subnet-74747474\",\"ZoneName\":\"us-west-2b\"}]}]}","expected_output":"{\n \"IpAddressType\": \"ipv4\",\n \"VpcId\": \"vpc-abcdabcd\",\n \"LoadBalancerArn\": \"arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b\",\n \"State\": {\n \"Code\": \"active\"\n },\n \"DNSName\": \"MY-LB2-9876556789.us-west-2.elb.amazonaws.com\",\n \"SecurityGroups\": [\n \"sg-88818881\"\n ],\n \"LoadBalancerName\": \"MY-LB2\",\n \"CreatedTime\": \"2018-01-01T00:00:00.000Z\",\n \"Scheme\": \"internet-facing\",\n \"Type\": \"application\",\n \"CanonicalHostedZoneId\": \"ZZZZZZZZZZZZZ\",\n \"AvailabilityZones\": [\n {\n \"SubnetId\": \"subnet-54545454\",\n \"ZoneName\": \"us-west-2a\"\n },\n {\n \"SubnetId\": \"subnet-64646464\",\n \"ZoneName\": \"us-west-2c\"\n },\n {\n \"SubnetId\": \"subnet-74747474\",\n \"ZoneName\": \"us-west-2b\"\n }\n ]\n}\n","validation_input":"{\"LoadBalancers\":[{\"IpAddressType\":\"ipv4\",\"VpcId\":\"vpc-test\",\"LoadBalancerArn\":\"arn:aws:test\",\"State\":{\"Code\":\"active\"},\"DNSName\":\"my-lb2-9876556789.us-west-2.elb.amazonaws.com\",\"SecurityGroups\":[],\"LoadBalancerName\":\"MY-LB2\",\"CreatedTime\":\"2018-01-01T00:00:00.000Z\",\"Scheme\":\"internal\",\"Type\":\"network\",\"CanonicalHostedZoneId\":\"YYYYYYYYYYY\",\"AvailabilityZones\":[]}]}","validation_output":"{\n \"IpAddressType\": \"ipv4\",\n \"VpcId\": \"vpc-test\",\n \"LoadBalancerArn\": \"arn:aws:test\",\n \"State\": {\n \"Code\": \"active\"\n },\n \"DNSName\": \"my-lb2-9876556789.us-west-2.elb.amazonaws.com\",\n \"SecurityGroups\": [],\n \"LoadBalancerName\": \"MY-LB2\",\n \"CreatedTime\": \"2018-01-01T00:00:00.000Z\",\n \"Scheme\": \"internal\",\n \"Type\": \"network\",\n \"CanonicalHostedZoneId\": \"YYYYYYYYYYY\",\n \"AvailabilityZones\": []\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51718102/filter-json-via-bash-case-insensitive","question_title":"filter json via bash - case insensitive","question_owner":"hey","answer_owner":"peak","answer_id":51718532,"question_score":5,"reviewed":true,"paraphrase_of":"so-51718102","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-51914316","request":"Transform the input JSON object by swapping keys and values, then sorting the entries in descending order of the new key's string length.","command":"jq 'to_entries | map(.key as $k | .key=.value | .value=$k ) | sort_by(.key|length) | reverse | from_entries'","input_text":"{\"root_path\": \"/www\", \"core_path\": \"/www/wp\", \"content_path\": \"/www/content\", \"vendor_path\": \"/www/vendor\"}","expected_output":"{\n \"/www/content\": \"content_path\",\n \"/www/vendor\": \"vendor_path\",\n \"/www/wp\": \"core_path\",\n \"/www\": \"root_path\"\n}\n","validation_input":"{\"a\": \"short\", \"b\": \"medium_val\", \"c\": \"very_long_value_string\"}","validation_output":"{\n \"very_long_value_string\": \"c\",\n \"medium_val\": \"b\",\n \"short\": \"a\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51914316/use-jq-in-bash-to-sort-object-properties-by-descending-length-of-their-value","question_title":"Use jq in Bash to sort object properties by descending length of their value","question_owner":"MikeSchinkel","answer_owner":"peak","answer_id":51914402,"question_score":8,"reviewed":true} {"id":"so-51914316-p1","request":"Invert the keys and values of the input JSON object, then sort the resulting entries by the length of the new keys in descending order.","command":"jq 'to_entries | map(.key as $k | .key=.value | .value=$k ) | sort_by(.key|length) | reverse | from_entries'","input_text":"{\"root_path\": \"/www\", \"core_path\": \"/www/wp\", \"content_path\": \"/www/content\", \"vendor_path\": \"/www/vendor\"}","expected_output":"{\n \"/www/content\": \"content_path\",\n \"/www/vendor\": \"vendor_path\",\n \"/www/wp\": \"core_path\",\n \"/www\": \"root_path\"\n}\n","validation_input":"{\"a\": \"short\", \"b\": \"medium_val\", \"c\": \"very_long_value_string\"}","validation_output":"{\n \"very_long_value_string\": \"c\",\n \"medium_val\": \"b\",\n \"short\": \"a\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/51914316/use-jq-in-bash-to-sort-object-properties-by-descending-length-of-their-value","question_title":"Use jq in Bash to sort object properties by descending length of their value","question_owner":"MikeSchinkel","answer_owner":"peak","answer_id":51914402,"question_score":8,"reviewed":true,"paraphrase_of":"so-51914316","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-52067816","request":"Filter the 'Snapshots' array to include only objects where the 'Description' contains 'myorg-database-b', and output the result as a valid JSON array.","command":"jq '[ .Snapshots[] | select(.Description | contains(\"myorg-database-b\")) ]'","input_text":"{\"Snapshots\":[{\"Description\":\"myorg-database-b redacted\",\"Encrypted\":false,\"VolumeId\":\"vol-1234\",\"State\":\"completed\",\"VolumeSize\":500,\"StartTime\":\"2018-08-28T17:52:14.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-2424\"},{\"Description\":\"other snapshot\",\"Encrypted\":false,\"VolumeId\":\"vol-9999\",\"State\":\"completed\",\"VolumeSize\":100,\"StartTime\":\"2018-08-28T19:01:18.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-9999\"},{\"Description\":\"myorg-database-b backup\",\"Encrypted\":false,\"VolumeId\":\"vol-23456\",\"State\":\"completed\",\"VolumeSize\":500,\"StartTime\":\"2018-08-28T19:01:18.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-5535\"}]}","expected_output":"[\n {\n \"Description\": \"myorg-database-b redacted\",\n \"Encrypted\": false,\n \"VolumeId\": \"vol-1234\",\n \"State\": \"completed\",\n \"VolumeSize\": 500,\n \"StartTime\": \"2018-08-28T17:52:14.000Z\",\n \"Progress\": \"100%\",\n \"OwnerId\": \"12345678\",\n \"SnapshotId\": \"snap-2424\"\n },\n {\n \"Description\": \"myorg-database-b backup\",\n \"Encrypted\": false,\n \"VolumeId\": \"vol-23456\",\n \"State\": \"completed\",\n \"VolumeSize\": 500,\n \"StartTime\": \"2018-08-28T19:01:18.000Z\",\n \"Progress\": \"100%\",\n \"OwnerId\": \"12345678\",\n \"SnapshotId\": \"snap-5535\"\n }\n]\n","validation_input":"{\"Snapshots\":[{\"Description\":\"myorg-database-b test\",\"Encrypted\":true,\"VolumeId\":\"vol-1\",\"State\":\"pending\",\"VolumeSize\":10,\"StartTime\":\"2020-01-01T00:00:00.000Z\",\"Progress\":\"50%\",\"OwnerId\":\"111\",\"SnapshotId\":\"snap-1\"},{\"Description\":\"unrelated\",\"Encrypted\":false,\"VolumeId\":\"vol-2\",\"State\":\"completed\",\"VolumeSize\":20,\"StartTime\":\"2020-01-02T00:00:00.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"222\",\"SnapshotId\":\"snap-2\"}]}","validation_output":"[\n {\n \"Description\": \"myorg-database-b test\",\n \"Encrypted\": true,\n \"VolumeId\": \"vol-1\",\n \"State\": \"pending\",\n \"VolumeSize\": 10,\n \"StartTime\": \"2020-01-01T00:00:00.000Z\",\n \"Progress\": \"50%\",\n \"OwnerId\": \"111\",\n \"SnapshotId\": \"snap-1\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52067816/how-to-get-jq-to-print-valid-json-after-applying-a-filter","question_title":"How to get jq to print valid json after applying a filter","question_owner":"Dan","answer_owner":"weirdan","answer_id":52067905,"question_score":8,"reviewed":true} {"id":"so-52067816-p1","request":"Select only those objects from the 'Snapshots' array whose 'Description' field contains 'myorg-database-b' and output them as a valid JSON array.","command":"jq '[ .Snapshots[] | select(.Description | contains(\"myorg-database-b\")) ]'","input_text":"{\"Snapshots\":[{\"Description\":\"myorg-database-b redacted\",\"Encrypted\":false,\"VolumeId\":\"vol-1234\",\"State\":\"completed\",\"VolumeSize\":500,\"StartTime\":\"2018-08-28T17:52:14.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-2424\"},{\"Description\":\"other snapshot\",\"Encrypted\":false,\"VolumeId\":\"vol-9999\",\"State\":\"completed\",\"VolumeSize\":100,\"StartTime\":\"2018-08-28T19:01:18.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-9999\"},{\"Description\":\"myorg-database-b backup\",\"Encrypted\":false,\"VolumeId\":\"vol-23456\",\"State\":\"completed\",\"VolumeSize\":500,\"StartTime\":\"2018-08-28T19:01:18.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"12345678\",\"SnapshotId\":\"snap-5535\"}]}","expected_output":"[\n {\n \"Description\": \"myorg-database-b redacted\",\n \"Encrypted\": false,\n \"VolumeId\": \"vol-1234\",\n \"State\": \"completed\",\n \"VolumeSize\": 500,\n \"StartTime\": \"2018-08-28T17:52:14.000Z\",\n \"Progress\": \"100%\",\n \"OwnerId\": \"12345678\",\n \"SnapshotId\": \"snap-2424\"\n },\n {\n \"Description\": \"myorg-database-b backup\",\n \"Encrypted\": false,\n \"VolumeId\": \"vol-23456\",\n \"State\": \"completed\",\n \"VolumeSize\": 500,\n \"StartTime\": \"2018-08-28T19:01:18.000Z\",\n \"Progress\": \"100%\",\n \"OwnerId\": \"12345678\",\n \"SnapshotId\": \"snap-5535\"\n }\n]\n","validation_input":"{\"Snapshots\":[{\"Description\":\"myorg-database-b test\",\"Encrypted\":true,\"VolumeId\":\"vol-1\",\"State\":\"pending\",\"VolumeSize\":10,\"StartTime\":\"2020-01-01T00:00:00.000Z\",\"Progress\":\"50%\",\"OwnerId\":\"111\",\"SnapshotId\":\"snap-1\"},{\"Description\":\"unrelated\",\"Encrypted\":false,\"VolumeId\":\"vol-2\",\"State\":\"completed\",\"VolumeSize\":20,\"StartTime\":\"2020-01-02T00:00:00.000Z\",\"Progress\":\"100%\",\"OwnerId\":\"222\",\"SnapshotId\":\"snap-2\"}]}","validation_output":"[\n {\n \"Description\": \"myorg-database-b test\",\n \"Encrypted\": true,\n \"VolumeId\": \"vol-1\",\n \"State\": \"pending\",\n \"VolumeSize\": 10,\n \"StartTime\": \"2020-01-01T00:00:00.000Z\",\n \"Progress\": \"50%\",\n \"OwnerId\": \"111\",\n \"SnapshotId\": \"snap-1\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52067816/how-to-get-jq-to-print-valid-json-after-applying-a-filter","question_title":"How to get jq to print valid json after applying a filter","question_owner":"Dan","answer_owner":"weirdan","answer_id":52067905,"question_score":8,"reviewed":true,"paraphrase_of":"so-52067816","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-52170924","request":"Given a JSON array containing objects with a 'discoveredEntities' array, update the 'checked' field to false for any entity where the 'name' is 'weather'.","command":"jq '[.[].discoveredEntities[] |= if (.name==\"weather\") then (.checked = false) else . end]'","input_text":"[\n {\n \"originalSourceId\": null,\n \"discoveredEntities\": [\n {\"name\": \"weather\", \"checked\": true, \"checkedBeforeEdit\": false},\n {\"name\": \"weather_2\", \"checked\": true, \"checkedBeforeEdit\": false}\n ]\n }\n]","expected_output":"[\n [\n {\n \"originalSourceId\": null,\n \"discoveredEntities\": [\n {\n \"name\": \"weather\",\n \"checked\": false,\n \"checkedBeforeEdit\": false\n },\n {\n \"name\": \"weather_2\",\n \"checked\": true,\n \"checkedBeforeEdit\": false\n }\n ]\n }\n ]\n]\n","validation_input":"[\n {\n \"originalSourceId\": 123,\n \"discoveredEntities\": [\n {\"name\": \"temp\", \"checked\": true, \"checkedBeforeEdit\": false},\n {\"name\": \"weather\", \"checked\": true, \"checkedBeforeEdit\": true},\n {\"name\": \"humidity\", \"checked\": false, \"checkedBeforeEdit\": false}\n ]\n }\n]","validation_output":"[\n [\n {\n \"originalSourceId\": 123,\n \"discoveredEntities\": [\n {\n \"name\": \"temp\",\n \"checked\": true,\n \"checkedBeforeEdit\": false\n },\n {\n \"name\": \"weather\",\n \"checked\": false,\n \"checkedBeforeEdit\": true\n },\n {\n \"name\": \"humidity\",\n \"checked\": false,\n \"checkedBeforeEdit\": false\n }\n ]\n }\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52170924/jq-conditional-update-an-array-element","question_title":"jq conditional update an array element","question_owner":"CLO","answer_owner":"CLO","answer_id":52172213,"question_score":5,"reviewed":true} {"id":"so-52170924-p1","request":"For a JSON array of objects containing a 'discoveredEntities' list, set the 'checked' property to false for any entity named 'weather'.","command":"jq '[.[].discoveredEntities[] |= if (.name==\"weather\") then (.checked = false) else . end]'","input_text":"[\n {\n \"originalSourceId\": null,\n \"discoveredEntities\": [\n {\"name\": \"weather\", \"checked\": true, \"checkedBeforeEdit\": false},\n {\"name\": \"weather_2\", \"checked\": true, \"checkedBeforeEdit\": false}\n ]\n }\n]","expected_output":"[\n [\n {\n \"originalSourceId\": null,\n \"discoveredEntities\": [\n {\n \"name\": \"weather\",\n \"checked\": false,\n \"checkedBeforeEdit\": false\n },\n {\n \"name\": \"weather_2\",\n \"checked\": true,\n \"checkedBeforeEdit\": false\n }\n ]\n }\n ]\n]\n","validation_input":"[\n {\n \"originalSourceId\": 123,\n \"discoveredEntities\": [\n {\"name\": \"temp\", \"checked\": true, \"checkedBeforeEdit\": false},\n {\"name\": \"weather\", \"checked\": true, \"checkedBeforeEdit\": true},\n {\"name\": \"humidity\", \"checked\": false, \"checkedBeforeEdit\": false}\n ]\n }\n]","validation_output":"[\n [\n {\n \"originalSourceId\": 123,\n \"discoveredEntities\": [\n {\n \"name\": \"temp\",\n \"checked\": true,\n \"checkedBeforeEdit\": false\n },\n {\n \"name\": \"weather\",\n \"checked\": false,\n \"checkedBeforeEdit\": true\n },\n {\n \"name\": \"humidity\",\n \"checked\": false,\n \"checkedBeforeEdit\": false\n }\n ]\n }\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52170924/jq-conditional-update-an-array-element","question_title":"jq conditional update an array element","question_owner":"CLO","answer_owner":"CLO","answer_id":52172213,"question_score":5,"reviewed":true,"paraphrase_of":"so-52170924","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-52303570","request":"Convert an array of objects with 'name' and 'value' fields into a single object where each 'name' is a key and its corresponding 'value' is the value.","command":"jq 'from_entries'","input_text":"[\n {\n \"name\": \"A\",\n \"value\": \"4\"\n },\n {\n \"name\": \"B\",\n \"value\": \"2\"\n },\n {\n \"name\": \"C\",\n \"value\": {\n \"X\": \"Something\",\n \"Y\": \"Else\"\n }\n }\n]","expected_output":"{\n \"A\": \"4\",\n \"B\": \"2\",\n \"C\": {\n \"X\": \"Something\",\n \"Y\": \"Else\"\n }\n}\n","validation_input":"[\n {\n \"name\": \"Key1\",\n \"value\": 100\n },\n {\n \"name\": \"Key2\",\n \"value\": [\n 1,\n 2,\n 3\n ]\n }\n]","validation_output":"{\n \"Key1\": 100,\n \"Key2\": [\n 1,\n 2,\n 3\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52303570/using-jq-convert-array-of-name-value-pairs-to-object-with-named-keys","question_title":"Using jq, convert array of name/value pairs to object with named keys","question_owner":"Josip Medved","answer_owner":"boweeb","answer_id":76175252,"question_score":7,"reviewed":true} {"id":"so-52303570-p1","request":"Transform an array of objects having 'name' and 'value' fields into a single object, using 'name' as the key and 'value' as the corresponding value.","command":"jq 'from_entries'","input_text":"[\n {\n \"name\": \"A\",\n \"value\": \"4\"\n },\n {\n \"name\": \"B\",\n \"value\": \"2\"\n },\n {\n \"name\": \"C\",\n \"value\": {\n \"X\": \"Something\",\n \"Y\": \"Else\"\n }\n }\n]","expected_output":"{\n \"A\": \"4\",\n \"B\": \"2\",\n \"C\": {\n \"X\": \"Something\",\n \"Y\": \"Else\"\n }\n}\n","validation_input":"[\n {\n \"name\": \"Key1\",\n \"value\": 100\n },\n {\n \"name\": \"Key2\",\n \"value\": [\n 1,\n 2,\n 3\n ]\n }\n]","validation_output":"{\n \"Key1\": 100,\n \"Key2\": [\n 1,\n 2,\n 3\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52303570/using-jq-convert-array-of-name-value-pairs-to-object-with-named-keys","question_title":"Using jq, convert array of name/value pairs to object with named keys","question_owner":"Josip Medved","answer_owner":"boweeb","answer_id":76175252,"question_score":7,"reviewed":true,"paraphrase_of":"so-52303570","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-52441157","request":"Given a JSON object containing an array of items, add a new property 'NEW_PROPERTY' to the nested 'something' object within each array item, setting its value to the 'name' of that item.","command":"jq '.array = [ .array[] | .something.NEW_PROPERTY = .name ]'","input_text":"{\n \"first\": {\"second\": \"A\"},\n \"array\": [\n {\"name\": \"AAA\", \"something\": {\"hola\": \"hi\"}},\n {\"name\": \"BBB\", \"something\": {\"hola\": \"hi\"}}\n ]\n}","expected_output":"{\n \"first\": {\n \"second\": \"A\"\n },\n \"array\": [\n {\n \"name\": \"AAA\",\n \"something\": {\n \"hola\": \"hi\",\n \"NEW_PROPERTY\": \"AAA\"\n }\n },\n {\n \"name\": \"BBB\",\n \"something\": {\n \"hola\": \"hi\",\n \"NEW_PROPERTY\": \"BBB\"\n }\n }\n ]\n}\n","validation_input":"{\n \"first\": {\"second\": \"B\"},\n \"array\": [\n {\"name\": \"XXX\", \"something\": {\"foo\": \"bar\"}},\n {\"name\": \"YYY\", \"something\": {\"foo\": \"baz\"}}\n ]\n}","validation_output":"{\n \"first\": {\n \"second\": \"B\"\n },\n \"array\": [\n {\n \"name\": \"XXX\",\n \"something\": {\n \"foo\": \"bar\",\n \"NEW_PROPERTY\": \"XXX\"\n }\n },\n {\n \"name\": \"YYY\",\n \"something\": {\n \"foo\": \"baz\",\n \"NEW_PROPERTY\": \"YYY\"\n }\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52441157/jq-add-properties-to-nested-object-in-nested-array","question_title":"JQ add properties to nested object in nested array","question_owner":"rascio","answer_owner":"oliv","answer_id":52442907,"question_score":5,"reviewed":true} {"id":"so-52441157-p1","request":"Iterate through the items array in a JSON object and add a 'NEW_PROPERTY' to the nested 'something' object in each item, assigning it the value of the item's 'name'.","command":"jq '.array = [ .array[] | .something.NEW_PROPERTY = .name ]'","input_text":"{\n \"first\": {\"second\": \"A\"},\n \"array\": [\n {\"name\": \"AAA\", \"something\": {\"hola\": \"hi\"}},\n {\"name\": \"BBB\", \"something\": {\"hola\": \"hi\"}}\n ]\n}","expected_output":"{\n \"first\": {\n \"second\": \"A\"\n },\n \"array\": [\n {\n \"name\": \"AAA\",\n \"something\": {\n \"hola\": \"hi\",\n \"NEW_PROPERTY\": \"AAA\"\n }\n },\n {\n \"name\": \"BBB\",\n \"something\": {\n \"hola\": \"hi\",\n \"NEW_PROPERTY\": \"BBB\"\n }\n }\n ]\n}\n","validation_input":"{\n \"first\": {\"second\": \"B\"},\n \"array\": [\n {\"name\": \"XXX\", \"something\": {\"foo\": \"bar\"}},\n {\"name\": \"YYY\", \"something\": {\"foo\": \"baz\"}}\n ]\n}","validation_output":"{\n \"first\": {\n \"second\": \"B\"\n },\n \"array\": [\n {\n \"name\": \"XXX\",\n \"something\": {\n \"foo\": \"bar\",\n \"NEW_PROPERTY\": \"XXX\"\n }\n },\n {\n \"name\": \"YYY\",\n \"something\": {\n \"foo\": \"baz\",\n \"NEW_PROPERTY\": \"YYY\"\n }\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52441157/jq-add-properties-to-nested-object-in-nested-array","question_title":"JQ add properties to nested object in nested array","question_owner":"rascio","answer_owner":"oliv","answer_id":52442907,"question_score":5,"reviewed":true,"paraphrase_of":"so-52441157","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-53448845","request":"Extract the Value from items in the TagList array where the Key is either \"Environment\" or \"ENVIRONMENT\".","command":"jq -r '.TagList[] | select(.Key == \"Environment\" or .Key == \"ENVIRONMENT\") | .Value'","input_text":"{\"TagList\": [{\"Key\": \"Environment\", \"Value\": \"foo\"}, {\"Key\": \"Other\", \"Value\": \"bar\"}]}","expected_output":"foo\n","validation_input":"{\"TagList\": [{\"Key\": \"ENVIRONMENT\", \"Value\": \"baz\"}, {\"Key\": \"Environment\", \"Value\": \"qux\"}]}","validation_output":"baz\nqux\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53448845/jq-select-or-statement","question_title":"jq select or statement","question_owner":"eekfonky","answer_owner":"hek2mgl","answer_id":53449125,"question_score":6,"reviewed":true} {"id":"so-53448845-p1","request":"Retrieve the Value from elements in the TagList array where the Key matches either \"Environment\" or \"ENVIRONMENT\".","command":"jq -r '.TagList[] | select(.Key == \"Environment\" or .Key == \"ENVIRONMENT\") | .Value'","input_text":"{\"TagList\": [{\"Key\": \"Environment\", \"Value\": \"foo\"}, {\"Key\": \"Other\", \"Value\": \"bar\"}]}","expected_output":"foo\n","validation_input":"{\"TagList\": [{\"Key\": \"ENVIRONMENT\", \"Value\": \"baz\"}, {\"Key\": \"Environment\", \"Value\": \"qux\"}]}","validation_output":"baz\nqux\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53448845/jq-select-or-statement","question_title":"jq select or statement","question_owner":"eekfonky","answer_owner":"hek2mgl","answer_id":53449125,"question_score":6,"reviewed":true,"paraphrase_of":"so-53448845","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-53512985","request":"Filter a JSON array of objects to include only those where the 'tags' array does not contain the string \"red\".","command":"jq '[.[] | select(.tags | index(\"red\") | not)]'","input_text":"[\n {\n \"name\": \"banana\",\n \"tags\": [\n \"yellow\",\n \"long\"\n ]\n },\n {\n \"name\": \"apple\",\n \"tags\": [\n \"red\",\n \"round\"\n ]\n },\n {\n \"name\": \"orange\",\n \"tags\": [\n \"orange\",\n \"round\",\n \"colored\"\n ]\n }\n]","expected_output":"[\n {\n \"name\": \"banana\",\n \"tags\": [\n \"yellow\",\n \"long\"\n ]\n },\n {\n \"name\": \"orange\",\n \"tags\": [\n \"orange\",\n \"round\",\n \"colored\"\n ]\n }\n]\n","validation_input":"[\n {\n \"name\": \"grape\",\n \"tags\": [\n \"purple\",\n \"small\"\n ]\n },\n {\n \"name\": \"strawberry\",\n \"tags\": [\n \"red\",\n \"sweet\"\n ]\n },\n {\n \"name\": \"kiwi\",\n \"tags\": [\n \"green\",\n \"fuzzy\"\n ]\n }\n]","validation_output":"[\n {\n \"name\": \"grape\",\n \"tags\": [\n \"purple\",\n \"small\"\n ]\n },\n {\n \"name\": \"kiwi\",\n \"tags\": [\n \"green\",\n \"fuzzy\"\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53512985/jq-filter-array-does-not-contain","question_title":"jq - filter array does not contain","question_owner":"TimRiker","answer_owner":"Kamal","answer_id":53513222,"question_score":6,"reviewed":true} {"id":"so-53512985-p1","request":"Filter a JSON array of objects to keep only those whose 'tags' array excludes the string \"red\".","command":"jq '[.[] | select(.tags | index(\"red\") | not)]'","input_text":"[\n {\n \"name\": \"banana\",\n \"tags\": [\n \"yellow\",\n \"long\"\n ]\n },\n {\n \"name\": \"apple\",\n \"tags\": [\n \"red\",\n \"round\"\n ]\n },\n {\n \"name\": \"orange\",\n \"tags\": [\n \"orange\",\n \"round\",\n \"colored\"\n ]\n }\n]","expected_output":"[\n {\n \"name\": \"banana\",\n \"tags\": [\n \"yellow\",\n \"long\"\n ]\n },\n {\n \"name\": \"orange\",\n \"tags\": [\n \"orange\",\n \"round\",\n \"colored\"\n ]\n }\n]\n","validation_input":"[\n {\n \"name\": \"grape\",\n \"tags\": [\n \"purple\",\n \"small\"\n ]\n },\n {\n \"name\": \"strawberry\",\n \"tags\": [\n \"red\",\n \"sweet\"\n ]\n },\n {\n \"name\": \"kiwi\",\n \"tags\": [\n \"green\",\n \"fuzzy\"\n ]\n }\n]","validation_output":"[\n {\n \"name\": \"grape\",\n \"tags\": [\n \"purple\",\n \"small\"\n ]\n },\n {\n \"name\": \"kiwi\",\n \"tags\": [\n \"green\",\n \"fuzzy\"\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53512985/jq-filter-array-does-not-contain","question_title":"jq - filter array does not contain","question_owner":"TimRiker","answer_owner":"Kamal","answer_id":53513222,"question_score":6,"reviewed":true,"paraphrase_of":"so-53512985","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-53721635","request":"Extract the 'processid' from all top-level objects whose keys start with 'Task'. The input is a single JSON object with dynamic keys.","command":"jq -c '[to_entries[] | select(.key | startswith(\"Task\")) | .value.attributes.processid]'","input_text":"{\n \"Task11c-0-20181209-12:59:30-65611\": {\n \"attributes\": {\n \"processid\": \"65611\"\n }\n },\n \"OtherKey\": {\n \"attributes\": {\n \"processid\": \"99999\"\n }\n },\n \"Task11b-12-20181209-13:03:17-65612\": {\n \"attributes\": {\n \"processid\": \"65612\"\n }\n }\n}","expected_output":"[\"65611\",\"65612\"]\n","validation_input":"{\n \"TaskA-1\": {\n \"attributes\": {\n \"processid\": \"101\"\n }\n },\n \"IgnoreMe\": {\n \"attributes\": {\n \"processid\": \"000\"\n }\n },\n \"TaskB-2\": {\n \"attributes\": {\n \"processid\": \"102\"\n }\n }\n}","validation_output":"[\"101\",\"102\"]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53721635/how-can-i-match-fields-with-wildcards-using-jq","question_title":"How can i match fields with wildcards using jq?","question_owner":"Alessandro","answer_owner":"Inian","answer_id":53722321,"question_score":10,"reviewed":true} {"id":"so-53721635-p1","request":"From a single JSON object with dynamic keys, extract the 'processid' from all top-level entries whose keys begin with 'Task'.","command":"jq -c '[to_entries[] | select(.key | startswith(\"Task\")) | .value.attributes.processid]'","input_text":"{\n \"Task11c-0-20181209-12:59:30-65611\": {\n \"attributes\": {\n \"processid\": \"65611\"\n }\n },\n \"OtherKey\": {\n \"attributes\": {\n \"processid\": \"99999\"\n }\n },\n \"Task11b-12-20181209-13:03:17-65612\": {\n \"attributes\": {\n \"processid\": \"65612\"\n }\n }\n}","expected_output":"[\"65611\",\"65612\"]\n","validation_input":"{\n \"TaskA-1\": {\n \"attributes\": {\n \"processid\": \"101\"\n }\n },\n \"IgnoreMe\": {\n \"attributes\": {\n \"processid\": \"000\"\n }\n },\n \"TaskB-2\": {\n \"attributes\": {\n \"processid\": \"102\"\n }\n }\n}","validation_output":"[\"101\",\"102\"]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/53721635/how-can-i-match-fields-with-wildcards-using-jq","question_title":"How can i match fields with wildcards using jq?","question_owner":"Alessandro","answer_owner":"Inian","answer_id":53722321,"question_score":10,"reviewed":true,"paraphrase_of":"so-53721635","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-54039268","request":"Update the 'value' field to 'new' for the environment variable named 'DB_USERNAME' within the first container definition.","command":"jq '( .taskDefinition.containerDefinitions[0].environment[] | select(.name==\"DB_USERNAME\") | .value ) |= \"new\"'","input_text":"{\"taskDefinition\":{\"containerDefinitions\":[{\"name\":\"web\",\"image\":\"my-image\",\"environment\":[{\"name\":\"DB_HOST\",\"value\":\"localhost\"},{\"name\":\"DB_USERNAME\",\"value\":\"user\"}]}]}}","expected_output":"{\n \"taskDefinition\": {\n \"containerDefinitions\": [\n {\n \"name\": \"web\",\n \"image\": \"my-image\",\n \"environment\": [\n {\n \"name\": \"DB_HOST\",\n \"value\": \"localhost\"\n },\n {\n \"name\": \"DB_USERNAME\",\n \"value\": \"new\"\n }\n ]\n }\n ]\n }\n}\n","validation_input":"{\"taskDefinition\":{\"containerDefinitions\":[{\"name\":\"app\",\"image\":\"img:v1\",\"environment\":[{\"name\":\"API_KEY\",\"value\":\"old_key\"},{\"name\":\"DB_USERNAME\",\"value\":\"admin\"},{\"name\":\"PORT\",\"value\":\"8080\"}]}]}}","validation_output":"{\n \"taskDefinition\": {\n \"containerDefinitions\": [\n {\n \"name\": \"app\",\n \"image\": \"img:v1\",\n \"environment\": [\n {\n \"name\": \"API_KEY\",\n \"value\": \"old_key\"\n },\n {\n \"name\": \"DB_USERNAME\",\n \"value\": \"new\"\n },\n {\n \"name\": \"PORT\",\n \"value\": \"8080\"\n }\n ]\n }\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54039268/modifying-array-of-key-value-in-json-jq","question_title":"Modifying array of key value in JSON jq","question_owner":"zdk","answer_owner":"Thor","answer_id":54041253,"question_score":8,"reviewed":true} {"id":"so-54039268-p1","request":"In the first container definition, change the 'value' field of the environment variable named 'DB_USERNAME' to 'new'.","command":"jq '( .taskDefinition.containerDefinitions[0].environment[] | select(.name==\"DB_USERNAME\") | .value ) |= \"new\"'","input_text":"{\"taskDefinition\":{\"containerDefinitions\":[{\"name\":\"web\",\"image\":\"my-image\",\"environment\":[{\"name\":\"DB_HOST\",\"value\":\"localhost\"},{\"name\":\"DB_USERNAME\",\"value\":\"user\"}]}]}}","expected_output":"{\n \"taskDefinition\": {\n \"containerDefinitions\": [\n {\n \"name\": \"web\",\n \"image\": \"my-image\",\n \"environment\": [\n {\n \"name\": \"DB_HOST\",\n \"value\": \"localhost\"\n },\n {\n \"name\": \"DB_USERNAME\",\n \"value\": \"new\"\n }\n ]\n }\n ]\n }\n}\n","validation_input":"{\"taskDefinition\":{\"containerDefinitions\":[{\"name\":\"app\",\"image\":\"img:v1\",\"environment\":[{\"name\":\"API_KEY\",\"value\":\"old_key\"},{\"name\":\"DB_USERNAME\",\"value\":\"admin\"},{\"name\":\"PORT\",\"value\":\"8080\"}]}]}}","validation_output":"{\n \"taskDefinition\": {\n \"containerDefinitions\": [\n {\n \"name\": \"app\",\n \"image\": \"img:v1\",\n \"environment\": [\n {\n \"name\": \"API_KEY\",\n \"value\": \"old_key\"\n },\n {\n \"name\": \"DB_USERNAME\",\n \"value\": \"new\"\n },\n {\n \"name\": \"PORT\",\n \"value\": \"8080\"\n }\n ]\n }\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54039268/modifying-array-of-key-value-in-json-jq","question_title":"Modifying array of key value in JSON jq","question_owner":"zdk","answer_owner":"Thor","answer_id":54041253,"question_score":8,"reviewed":true,"paraphrase_of":"so-54039268","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-54087732","request":"From a JSON object containing an 'entries' array, select objects where the 'icon' field contains the string 'BBC' and output their 'uuid'. Suppress errors if the 'icon' key is missing or not a string.","command":"jq '.entries[] | select(.icon | try contains(\"BBC\")) | .uuid'","input_text":"{\"entries\": [{\"uuid\": \"174501xxxxxxxxxxxxxe6342a03\", \"enabled\": true, \"autoname\": true, \"name\": \"BBC\", \"number\": 0, \"icon\": \"file:///logos/BBC.png\", \"icon_public_url\": \"imagecache/1097\", \"epgauto\": true, \"epggrab\": [], \"dvr_pre_time\": 0, \"dvr_pst_time\": 0, \"epg_running\": -1, \"services\": [], \"tags\": [], \"bouquet\": \"\"}, {\"uuid\": \"174501xxxxxxxxxxxxxe6342a04\", \"enabled\": true, \"autoname\": true, \"name\": \"ABC\", \"number\": 0, \"icon_public_url\": \"imagecache/1098\", \"epgauto\": true, \"epggrab\": [], \"dvr_pre_time\": 0, \"dvr_pst_time\": 0, \"epg_running\": -1, \"services\": [], \"tags\": [], \"bouquet\": \"\"}]}","expected_output":"\"174501xxxxxxxxxxxxxe6342a03\"\n","validation_input":"{\"entries\": [{\"uuid\": \"abc-123\", \"icon\": \"http://example.com/BBC_logo.png\"}, {\"uuid\": \"def-456\", \"icon\": null}, {\"uuid\": \"ghi-789\", \"name\": \"No Icon Field\"}]}","validation_output":"\"abc-123\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54087732/use-jq-contains-and-suppress-errors-when-key-not-found","question_title":"Use JQ "contains" and suppress errors when key not found","question_owner":"mfaiz","answer_owner":"AKstat","answer_id":54087993,"question_score":7,"reviewed":true} {"id":"so-54087732-p1","request":"From a JSON object with an 'entries' array, return the 'uuid' of objects where the 'icon' field includes the string 'BBC', ignoring errors if 'icon' is missing or not a string.","command":"jq '.entries[] | select(.icon | try contains(\"BBC\")) | .uuid'","input_text":"{\"entries\": [{\"uuid\": \"174501xxxxxxxxxxxxxe6342a03\", \"enabled\": true, \"autoname\": true, \"name\": \"BBC\", \"number\": 0, \"icon\": \"file:///logos/BBC.png\", \"icon_public_url\": \"imagecache/1097\", \"epgauto\": true, \"epggrab\": [], \"dvr_pre_time\": 0, \"dvr_pst_time\": 0, \"epg_running\": -1, \"services\": [], \"tags\": [], \"bouquet\": \"\"}, {\"uuid\": \"174501xxxxxxxxxxxxxe6342a04\", \"enabled\": true, \"autoname\": true, \"name\": \"ABC\", \"number\": 0, \"icon_public_url\": \"imagecache/1098\", \"epgauto\": true, \"epggrab\": [], \"dvr_pre_time\": 0, \"dvr_pst_time\": 0, \"epg_running\": -1, \"services\": [], \"tags\": [], \"bouquet\": \"\"}]}","expected_output":"\"174501xxxxxxxxxxxxxe6342a03\"\n","validation_input":"{\"entries\": [{\"uuid\": \"abc-123\", \"icon\": \"http://example.com/BBC_logo.png\"}, {\"uuid\": \"def-456\", \"icon\": null}, {\"uuid\": \"ghi-789\", \"name\": \"No Icon Field\"}]}","validation_output":"\"abc-123\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54087732/use-jq-contains-and-suppress-errors-when-key-not-found","question_title":"Use JQ "contains" and suppress errors when key not found","question_owner":"mfaiz","answer_owner":"AKstat","answer_id":54087993,"question_score":7,"reviewed":true,"paraphrase_of":"so-54087732","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-54184147","request":"Convert the input JSON object into a series of lines where each line is formatted as 'KEY=VALUE'. Ensure that numeric values are converted to strings before concatenation.","command":"jq -r 'to_entries | .[] | .key + \"=\" + (.value|tostring)'","input_text":"{\"REGION\": \"us-east-1\", \"EMAIL\": \"contain\", \"UPDATE\": 1}","expected_output":"REGION=us-east-1\nEMAIL=contain\nUPDATE=1\n","validation_input":"{\"NAME\": \"test\", \"COUNT\": 5, \"ACTIVE\": true}","validation_output":"NAME=test\nCOUNT=5\nACTIVE=true\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54184147/jq-to-entries-string-and-number-cannot-be-added","question_title":"jq to_entries string and number cannot be added","question_owner":"Alex","answer_owner":"peak","answer_id":54184316,"question_score":5,"reviewed":true} {"id":"so-54184147-p1","request":"Transform the input JSON object into lines formatted as 'KEY=VALUE', ensuring numeric values are cast to strings before concatenation.","command":"jq -r 'to_entries | .[] | .key + \"=\" + (.value|tostring)'","input_text":"{\"REGION\": \"us-east-1\", \"EMAIL\": \"contain\", \"UPDATE\": 1}","expected_output":"REGION=us-east-1\nEMAIL=contain\nUPDATE=1\n","validation_input":"{\"NAME\": \"test\", \"COUNT\": 5, \"ACTIVE\": true}","validation_output":"NAME=test\nCOUNT=5\nACTIVE=true\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54184147/jq-to-entries-string-and-number-cannot-be-added","question_title":"jq to_entries string and number cannot be added","question_owner":"Alex","answer_owner":"peak","answer_id":54184316,"question_score":5,"reviewed":true,"paraphrase_of":"so-54184147","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-54334293","request":"Read a JSON object from stdin representing an Amazon inventory. Construct a new object that retains the 'activeitem' value and adds an 'item' field containing the first item from the 'items' array whose name contains the string 'shoes'. Remove the original 'items' array.","command":"jq '{activeitem: .amazon.activeitem, item: (.amazon.items | map(select(.name | contains(\"shoes\")))[0])}'","input_text":"{\"amazon\": {\"activeitem\": 2, \"items\": [{\"id\": 1, \"name\": \"harry potter\", \"state\": \"sold\"}, {\"id\": 2, \"name\": \"adidas shoes\", \"state\": \"in inventory\"}, {\"id\": 3, \"name\": \"watch\", \"state\": \"returned\"}, {\"id\": 4, \"name\": \"adidas shoes\", \"state\": \"in inventory\"}]}}","expected_output":"{\n \"activeitem\": 2,\n \"item\": {\n \"id\": 2,\n \"name\": \"adidas shoes\",\n \"state\": \"in inventory\"\n }\n}\n","validation_input":"{\"amazon\": {\"activeitem\": 5, \"items\": [{\"id\": 10, \"name\": \"socks\", \"state\": \"new\"}, {\"id\": 11, \"name\": \"running shoes\", \"state\": \"used\"}, {\"id\": 12, \"name\": \"hat\", \"state\": \"new\"}]}}","validation_output":"{\n \"activeitem\": 5,\n \"item\": {\n \"id\": 11,\n \"name\": \"running shoes\",\n \"state\": \"used\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54334293/selecting-in-jq-with-contains-in-a-array","question_title":"Selecting in JQ with Contains in a Array","question_owner":"Aksanth","answer_owner":"peak","answer_id":54337162,"question_score":5,"reviewed":true} {"id":"so-54334293-p1","request":"Read an Amazon inventory JSON object from stdin, create a new object keeping the 'activeitem' and adding an 'item' field with the first entry from 'items' containing 'shoes' in its name, while removing the original 'items' array.","command":"jq '{activeitem: .amazon.activeitem, item: (.amazon.items | map(select(.name | contains(\"shoes\")))[0])}'","input_text":"{\"amazon\": {\"activeitem\": 2, \"items\": [{\"id\": 1, \"name\": \"harry potter\", \"state\": \"sold\"}, {\"id\": 2, \"name\": \"adidas shoes\", \"state\": \"in inventory\"}, {\"id\": 3, \"name\": \"watch\", \"state\": \"returned\"}, {\"id\": 4, \"name\": \"adidas shoes\", \"state\": \"in inventory\"}]}}","expected_output":"{\n \"activeitem\": 2,\n \"item\": {\n \"id\": 2,\n \"name\": \"adidas shoes\",\n \"state\": \"in inventory\"\n }\n}\n","validation_input":"{\"amazon\": {\"activeitem\": 5, \"items\": [{\"id\": 10, \"name\": \"socks\", \"state\": \"new\"}, {\"id\": 11, \"name\": \"running shoes\", \"state\": \"used\"}, {\"id\": 12, \"name\": \"hat\", \"state\": \"new\"}]}}","validation_output":"{\n \"activeitem\": 5,\n \"item\": {\n \"id\": 11,\n \"name\": \"running shoes\",\n \"state\": \"used\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54334293/selecting-in-jq-with-contains-in-a-array","question_title":"Selecting in JQ with Contains in a Array","question_owner":"Aksanth","answer_owner":"peak","answer_id":54337162,"question_score":5,"reviewed":true,"paraphrase_of":"so-54334293","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-54624827","request":"Count the number of objects in the input array where the 'status' is 'skipped' and the 'ref' starts with 'v1.4.15'.","command":"jq '[.[] | select(.status == \"skipped\" and (.ref | startswith(\"v1.4.15\")))] | length'","input_text":"[{\"id\": 15264, \"ref\": \"v1.4.15-static\", \"status\": \"skipped\"}, {\"id\": 15263, \"ref\": \"v1.4.15-static\", \"status\": \"skipped\"}, {\"id\": 15262, \"ref\": \"v1.4.15-no-js\", \"status\": \"skipped\"}, {\"id\": 15261, \"ref\": \"dev\", \"status\": \"skipped\"}, {\"id\": 15260, \"ref\": \"v1.4.15-cli\", \"status\": \"success\"}]","expected_output":"3\n","validation_input":"[{\"id\": 1, \"ref\": \"v1.4.15-test\", \"status\": \"skipped\"}, {\"id\": 2, \"ref\": \"v1.4.15\", \"status\": \"skipped\"}, {\"id\": 3, \"ref\": \"v1.4.16\", \"status\": \"skipped\"}, {\"id\": 4, \"ref\": \"v1.4.15-old\", \"status\": \"failed\"}]","validation_output":"2\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54624827/jq-how-to-count-depending-on-conditions","question_title":"JQ, how to count depending on conditions?","question_owner":"Dimitri Kopriwa","answer_owner":"Inian","answer_id":54624970,"question_score":8,"reviewed":true} {"id":"so-54624827-p1","request":"Count how many objects in the input array have a 'status' of 'skipped' and a 'ref' that begins with 'v1.4.15'.","command":"jq '[.[] | select(.status == \"skipped\" and (.ref | startswith(\"v1.4.15\")))] | length'","input_text":"[{\"id\": 15264, \"ref\": \"v1.4.15-static\", \"status\": \"skipped\"}, {\"id\": 15263, \"ref\": \"v1.4.15-static\", \"status\": \"skipped\"}, {\"id\": 15262, \"ref\": \"v1.4.15-no-js\", \"status\": \"skipped\"}, {\"id\": 15261, \"ref\": \"dev\", \"status\": \"skipped\"}, {\"id\": 15260, \"ref\": \"v1.4.15-cli\", \"status\": \"success\"}]","expected_output":"3\n","validation_input":"[{\"id\": 1, \"ref\": \"v1.4.15-test\", \"status\": \"skipped\"}, {\"id\": 2, \"ref\": \"v1.4.15\", \"status\": \"skipped\"}, {\"id\": 3, \"ref\": \"v1.4.16\", \"status\": \"skipped\"}, {\"id\": 4, \"ref\": \"v1.4.15-old\", \"status\": \"failed\"}]","validation_output":"2\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/54624827/jq-how-to-count-depending-on-conditions","question_title":"JQ, how to count depending on conditions?","question_owner":"Dimitri Kopriwa","answer_owner":"Inian","answer_id":54624970,"question_score":8,"reviewed":true,"paraphrase_of":"so-54624827","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-55251603","request":"Extract credential objects from a JSON structure where the 'credhub-ref' key exists within the credentials object. Output each matching credential object on a separate line.","command":"jq -r '.resources[].entity.credentials | select(has(\"credhub-ref\"))'","input_text":"{\n \"total_results\": 23,\n \"total_pages\": 1,\n \"prev_url\": null,\n \"next_url\": null,\n \"resources\": [\n {\n \"entity\": {\n \"credentials\": {},\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2018-10-15T19:13:57Z\",\n \"created_at\": \"2018-10-15T19:13:57Z\"\n },\n \"app_url\": \"/v2/3\"\n }\n },\n {\n \"entity\": {\n \"app_guid\": \"sd\",\n \"service_instance_guid\": \"sd\",\n \"credentials\": {\n \"hostname\": \"w\",\n \"port\": 3306\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2018-10-15T19:24:06Z\",\n \"created_at\": \"2018-10-15T19:24:06Z\"\n },\n \"app_url\": \"/v2/3\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"ref3\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2019-03-19T20:07:27Z\",\n \"created_at\": \"2019-03-19T20:07:27Z\"\n },\n \"app_url\": \"/v2/45\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"ref4\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2019-03-19T20:07:27Z\",\n \"created_at\": \"2019-03-19T20:07:27Z\"\n },\n \"app_url\": \"/v2/45\"\n }\n }\n ]\n}","expected_output":"{\n \"credhub-ref\": \"ref3\"\n}\n{\n \"credhub-ref\": \"ref4\"\n}\n","validation_input":"{\n \"total_results\": 2,\n \"total_pages\": 1,\n \"prev_url\": null,\n \"next_url\": null,\n \"resources\": [\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"refA\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2020-01-01T00:00:00Z\",\n \"created_at\": \"2020-01-01T00:00:00Z\"\n },\n \"app_url\": \"/v2/1\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"username\": \"admin\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2020-01-02T00:00:00Z\",\n \"created_at\": \"2020-01-02T00:00:00Z\"\n },\n \"app_url\": \"/v2/2\"\n }\n }\n ]\n}","validation_output":"{\n \"credhub-ref\": \"refA\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/55251603/jq-select-objects-where-inner-key-exists","question_title":"JQ Select Objects Where Inner Key Exists","question_owner":"Radford","answer_owner":"oguz ismail","answer_id":55251776,"question_score":6,"reviewed":true} {"id":"so-55251603-p1","request":"Extract and output each credential object on a new line from a JSON structure where the credentials object contains a 'credhub-ref' key.","command":"jq -r '.resources[].entity.credentials | select(has(\"credhub-ref\"))'","input_text":"{\n \"total_results\": 23,\n \"total_pages\": 1,\n \"prev_url\": null,\n \"next_url\": null,\n \"resources\": [\n {\n \"entity\": {\n \"credentials\": {},\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2018-10-15T19:13:57Z\",\n \"created_at\": \"2018-10-15T19:13:57Z\"\n },\n \"app_url\": \"/v2/3\"\n }\n },\n {\n \"entity\": {\n \"app_guid\": \"sd\",\n \"service_instance_guid\": \"sd\",\n \"credentials\": {\n \"hostname\": \"w\",\n \"port\": 3306\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2018-10-15T19:24:06Z\",\n \"created_at\": \"2018-10-15T19:24:06Z\"\n },\n \"app_url\": \"/v2/3\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"ref3\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2019-03-19T20:07:27Z\",\n \"created_at\": \"2019-03-19T20:07:27Z\"\n },\n \"app_url\": \"/v2/45\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"ref4\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2019-03-19T20:07:27Z\",\n \"created_at\": \"2019-03-19T20:07:27Z\"\n },\n \"app_url\": \"/v2/45\"\n }\n }\n ]\n}","expected_output":"{\n \"credhub-ref\": \"ref3\"\n}\n{\n \"credhub-ref\": \"ref4\"\n}\n","validation_input":"{\n \"total_results\": 2,\n \"total_pages\": 1,\n \"prev_url\": null,\n \"next_url\": null,\n \"resources\": [\n {\n \"entity\": {\n \"credentials\": {\n \"credhub-ref\": \"refA\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2020-01-01T00:00:00Z\",\n \"created_at\": \"2020-01-01T00:00:00Z\"\n },\n \"app_url\": \"/v2/1\"\n }\n },\n {\n \"entity\": {\n \"credentials\": {\n \"username\": \"admin\"\n },\n \"binding_options\": {},\n \"gateway_data\": null,\n \"gateway_name\": \"\",\n \"syslog_drain_url\": null,\n \"volume_mounts\": [],\n \"name\": null,\n \"last_operation\": {\n \"type\": \"create\",\n \"state\": \"succeeded\",\n \"description\": \"\",\n \"updated_at\": \"2020-01-02T00:00:00Z\",\n \"created_at\": \"2020-01-02T00:00:00Z\"\n },\n \"app_url\": \"/v2/2\"\n }\n }\n ]\n}","validation_output":"{\n \"credhub-ref\": \"refA\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/55251603/jq-select-objects-where-inner-key-exists","question_title":"JQ Select Objects Where Inner Key Exists","question_owner":"Radford","answer_owner":"oguz ismail","answer_id":55251776,"question_score":6,"reviewed":true,"paraphrase_of":"so-55251603","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-55606056","request":"Given a JSON array of objects on stdin, output each object in the array as a separate compact JSON line.","command":"jq -c '.[]'","input_text":"[{\"key\": \"IGNORE_VALIDATION_ERROR\", \"value\": \"true\", \"tags\": []}, {\"key\": \"BB_CFG_REPO_NAME\", \"value\": \"cd-tool-cfg\", \"tags\": []}]","expected_output":"{\"key\":\"IGNORE_VALIDATION_ERROR\",\"value\":\"true\",\"tags\":[]}\n{\"key\":\"BB_CFG_REPO_NAME\",\"value\":\"cd-tool-cfg\",\"tags\":[]}\n","validation_input":"[{\"id\": 1, \"status\": \"active\"}, {\"id\": 2, \"status\": \"inactive\"}]","validation_output":"{\"id\":1,\"status\":\"active\"}\n{\"id\":2,\"status\":\"inactive\"}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/55606056/compare-2-json-arrays-and-return-the-difference","question_title":"compare 2 json arrays and return the difference","question_owner":"Unfaced","answer_owner":"KamilCuk","answer_id":55606167,"question_score":6,"reviewed":true} {"id":"so-55606056-p1","request":"Read a JSON array of objects from stdin and print each object as a separate compact JSON line.","command":"jq -c '.[]'","input_text":"[{\"key\": \"IGNORE_VALIDATION_ERROR\", \"value\": \"true\", \"tags\": []}, {\"key\": \"BB_CFG_REPO_NAME\", \"value\": \"cd-tool-cfg\", \"tags\": []}]","expected_output":"{\"key\":\"IGNORE_VALIDATION_ERROR\",\"value\":\"true\",\"tags\":[]}\n{\"key\":\"BB_CFG_REPO_NAME\",\"value\":\"cd-tool-cfg\",\"tags\":[]}\n","validation_input":"[{\"id\": 1, \"status\": \"active\"}, {\"id\": 2, \"status\": \"inactive\"}]","validation_output":"{\"id\":1,\"status\":\"active\"}\n{\"id\":2,\"status\":\"inactive\"}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/55606056/compare-2-json-arrays-and-return-the-difference","question_title":"compare 2 json arrays and return the difference","question_owner":"Unfaced","answer_owner":"KamilCuk","answer_id":55606167,"question_score":6,"reviewed":true,"paraphrase_of":"so-55606056","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-56444091","request":"Extract the node name and the stdout result from each item in the items array, formatting them as a single line separated by a space.","command":"jq -r '.items[] | .node + \" \" + .result.stdout'","input_text":"{\"items\":[{\"node\":\"aaaa-cn001.me.com\",\"status\":\"success\",\"result\":{\"stdout\":\"3.10.0-957.12.1.el7.x86_64\\n\",\"stderr\":\"\",\"exit_code\":0}},{\"node\":\"aaaa-cn002.me.com\",\"status\":\"success\",\"result\":{\"stdout\":\"3.10.0-957.10.1.el7.x86_64\\n\",\"stderr\":\"\",\"exit_code\":0}}]}","expected_output":"aaaa-cn001.me.com 3.10.0-957.12.1.el7.x86_64\n\naaaa-cn002.me.com 3.10.0-957.10.1.el7.x86_64\n\n","validation_input":"{\"items\":[{\"node\":\"server-a\",\"status\":\"success\",\"result\":{\"stdout\":\"v1.0\\n\",\"stderr\":\"\",\"exit_code\":0}},{\"node\":\"server-b\",\"status\":\"failed\",\"result\":{\"stdout\":\"v2.0\\n\",\"stderr\":\"error\",\"exit_code\":1}}]}","validation_output":"server-a v1.0\n\nserver-b v2.0\n\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56444091/how-to-extract-fields-from-a-json-string-using-jq","question_title":"How to extract fields from a json string using jq","question_owner":"rony thomas","answer_owner":"Aaron","answer_id":56444177,"question_score":5,"reviewed":true} {"id":"so-56444091-p1","request":"For each item in the items array, extract the node name and stdout result, formatting them as a single space-separated line.","command":"jq -r '.items[] | .node + \" \" + .result.stdout'","input_text":"{\"items\":[{\"node\":\"aaaa-cn001.me.com\",\"status\":\"success\",\"result\":{\"stdout\":\"3.10.0-957.12.1.el7.x86_64\\n\",\"stderr\":\"\",\"exit_code\":0}},{\"node\":\"aaaa-cn002.me.com\",\"status\":\"success\",\"result\":{\"stdout\":\"3.10.0-957.10.1.el7.x86_64\\n\",\"stderr\":\"\",\"exit_code\":0}}]}","expected_output":"aaaa-cn001.me.com 3.10.0-957.12.1.el7.x86_64\n\naaaa-cn002.me.com 3.10.0-957.10.1.el7.x86_64\n\n","validation_input":"{\"items\":[{\"node\":\"server-a\",\"status\":\"success\",\"result\":{\"stdout\":\"v1.0\\n\",\"stderr\":\"\",\"exit_code\":0}},{\"node\":\"server-b\",\"status\":\"failed\",\"result\":{\"stdout\":\"v2.0\\n\",\"stderr\":\"error\",\"exit_code\":1}}]}","validation_output":"server-a v1.0\n\nserver-b v2.0\n\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56444091/how-to-extract-fields-from-a-json-string-using-jq","question_title":"How to extract fields from a json string using jq","question_owner":"rony thomas","answer_owner":"Aaron","answer_id":56444177,"question_score":5,"reviewed":true,"paraphrase_of":"so-56444091","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-56861281","request":"Multiply the numeric values of fields 'p' and 'q', which are provided as strings in the JSON input, and output the raw result.","command":"jq -r '(.p | tonumber) * (.q | tonumber)'","input_text":"{\"e\":\"aggTrade\",\"E\":1562109562958,\"s\":\"BTCUSDT\",\"a\":134343336,\"p\":\"10796.60000000\",\"q\":\"0.00139000\",\"f\":147532295,\"l\":147532295,\"T\":1562109562951,\"m\":false,\"M\":true}","expected_output":"15.007274\n","validation_input":"{\"e\":\"aggTrade\",\"E\":1562109562958,\"s\":\"ETHUSDT\",\"a\":134343337,\"p\":\"2000.50000000\",\"q\":\"0.50000000\",\"f\":147532296,\"l\":147532296,\"T\":1562109562952,\"m\":false,\"M\":true}","validation_output":"1000.25\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56861281/jq-how-to-multiply-values-that-are-recognised-as-strings","question_title":"JQ: How to multiply values that are recognised as strings?","question_owner":"user11731610","answer_owner":"Sufiyan Ghori","answer_id":56861410,"question_score":5,"reviewed":true} {"id":"so-56861281-p1","request":"Multiply the numeric values of the string fields 'p' and 'q' from the JSON input and output the raw product.","command":"jq -r '(.p | tonumber) * (.q | tonumber)'","input_text":"{\"e\":\"aggTrade\",\"E\":1562109562958,\"s\":\"BTCUSDT\",\"a\":134343336,\"p\":\"10796.60000000\",\"q\":\"0.00139000\",\"f\":147532295,\"l\":147532295,\"T\":1562109562951,\"m\":false,\"M\":true}","expected_output":"15.007274\n","validation_input":"{\"e\":\"aggTrade\",\"E\":1562109562958,\"s\":\"ETHUSDT\",\"a\":134343337,\"p\":\"2000.50000000\",\"q\":\"0.50000000\",\"f\":147532296,\"l\":147532296,\"T\":1562109562952,\"m\":false,\"M\":true}","validation_output":"1000.25\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/56861281/jq-how-to-multiply-values-that-are-recognised-as-strings","question_title":"JQ: How to multiply values that are recognised as strings?","question_owner":"user11731610","answer_owner":"Sufiyan Ghori","answer_id":56861410,"question_score":5,"reviewed":true,"paraphrase_of":"so-56861281","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-57069940","request":"Transform a JSON object by parsing the 'b' field as JSON into 'b2' if it exists and is not null; otherwise, omit 'b2' from the output while keeping 'a' and 'c'.","command":"jq 'if .b != null then { a, \"b2\":(.b|fromjson), c } else {a, c} end'","input_text":"{\"a\": 123, \"b\": \"{\\\"embedded\\\": 456}\", \"c\": 789}","expected_output":"{\n \"a\": 123,\n \"b2\": {\n \"embedded\": 456\n },\n \"c\": 789\n}\n","validation_input":"{\"a\": 123, \"c\": 789}","validation_output":"{\n \"a\": 123,\n \"c\": 789\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57069940/jq-json-handle-missing-fields","question_title":"jq JSON handle missing fields","question_owner":"clay","answer_owner":"Inian","answer_id":57070757,"question_score":7,"reviewed":true} {"id":"so-57069940-p1","request":"Parse the 'b' field as JSON into a new 'b2' key if it exists and is not null; otherwise, exclude 'b2' from the result while retaining 'a' and 'c'.","command":"jq 'if .b != null then { a, \"b2\":(.b|fromjson), c } else {a, c} end'","input_text":"{\"a\": 123, \"b\": \"{\\\"embedded\\\": 456}\", \"c\": 789}","expected_output":"{\n \"a\": 123,\n \"b2\": {\n \"embedded\": 456\n },\n \"c\": 789\n}\n","validation_input":"{\"a\": 123, \"c\": 789}","validation_output":"{\n \"a\": 123,\n \"c\": 789\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57069940/jq-json-handle-missing-fields","question_title":"jq JSON handle missing fields","question_owner":"clay","answer_owner":"Inian","answer_id":57070757,"question_score":7,"reviewed":true,"paraphrase_of":"so-57069940","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-57071166","request":"Given a JSON array of objects with semantic version strings in the 'version' field, return the object with the highest version number by comparing major, minor, and patch numerically.","command":"jq 'sort_by(.version | split(\".\") | map(tonumber))[-1]'","input_text":"[\n {\"name\": \"nodejs\", \"version\": \"0.1.21\", \"apiVersion\": \"v1\"},\n {\"name\": \"nodejs\", \"version\": \"0.1.20\", \"apiVersion\": \"v1\"},\n {\"name\": \"nodejs\", \"version\": \"0.1.11\", \"apiVersion\": \"v1\"}\n]","expected_output":"{\n \"name\": \"nodejs\",\n \"version\": \"0.1.21\",\n \"apiVersion\": \"v1\"\n}\n","validation_input":"[\n {\"name\": \"app\", \"version\": \"1.0.9\", \"apiVersion\": \"v2\"},\n {\"name\": \"app\", \"version\": \"1.0.21\", \"apiVersion\": \"v2\"},\n {\"name\": \"app\", \"version\": \"1.0.8\", \"apiVersion\": \"v2\"}\n]","validation_output":"{\n \"name\": \"app\",\n \"version\": \"1.0.21\",\n \"apiVersion\": \"v2\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57071166/jq-find-the-max-in-quoted-values","question_title":"jq find the max in quoted values","question_owner":"Nicolas Pepinster","answer_owner":"Inian","answer_id":57071319,"question_score":5,"reviewed":true} {"id":"so-57071166-p1","request":"From a JSON array of objects containing semantic version strings in the 'version' field, identify and return the object with the highest version by numerically comparing major, minor, and patch components.","command":"jq 'sort_by(.version | split(\".\") | map(tonumber))[-1]'","input_text":"[\n {\"name\": \"nodejs\", \"version\": \"0.1.21\", \"apiVersion\": \"v1\"},\n {\"name\": \"nodejs\", \"version\": \"0.1.20\", \"apiVersion\": \"v1\"},\n {\"name\": \"nodejs\", \"version\": \"0.1.11\", \"apiVersion\": \"v1\"}\n]","expected_output":"{\n \"name\": \"nodejs\",\n \"version\": \"0.1.21\",\n \"apiVersion\": \"v1\"\n}\n","validation_input":"[\n {\"name\": \"app\", \"version\": \"1.0.9\", \"apiVersion\": \"v2\"},\n {\"name\": \"app\", \"version\": \"1.0.21\", \"apiVersion\": \"v2\"},\n {\"name\": \"app\", \"version\": \"1.0.8\", \"apiVersion\": \"v2\"}\n]","validation_output":"{\n \"name\": \"app\",\n \"version\": \"1.0.21\",\n \"apiVersion\": \"v2\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57071166/jq-find-the-max-in-quoted-values","question_title":"jq find the max in quoted values","question_owner":"Nicolas Pepinster","answer_owner":"Inian","answer_id":57071319,"question_score":5,"reviewed":true,"paraphrase_of":"so-57071166","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-57154970","request":"Transform a flat JSON object with underscore-separated keys into a nested JSON object. Split each key by underscores to determine the path, and set the corresponding value in the nested structure.","command":"jq 'reduce to_entries[] as $kv ({}; setpath($kv.key|split(\"_\"); $kv.value))'","input_text":"{\"X1_X1o1_X1o1o1\": \"abc\",\"X1_X1o1_X1o1o2\": \"def\",\"X1_X1o2_X1o2o1\": \"ghi\",\"X1_X1o2_X1o2o2\": \"jkl\",\"X1_X1o3\": \"mno\",\"X2\": \"pqr\"}","expected_output":"{\n \"X1\": {\n \"X1o1\": {\n \"X1o1o1\": \"abc\",\n \"X1o1o2\": \"def\"\n },\n \"X1o2\": {\n \"X1o2o1\": \"ghi\",\n \"X1o2o2\": \"jkl\"\n },\n \"X1o3\": \"mno\"\n },\n \"X2\": \"pqr\"\n}\n","validation_input":"{\"a_b_c\": 1,\"a_b_d\": 2,\"a_e\": 3,\"f\": 4}","validation_output":"{\n \"a\": {\n \"b\": {\n \"c\": 1,\n \"d\": 2\n },\n \"e\": 3\n },\n \"f\": 4\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57154970/how-to-get-inverse-operation-of-flatten-for-objects-using-jq","question_title":"How to get inverse operation of flatten for objects using jq?","question_owner":"laracee","answer_owner":"peak","answer_id":57155523,"question_score":7,"reviewed":true} {"id":"so-57154970-p1","request":"Convert a flat JSON object with underscore-delimited keys into a nested structure by splitting keys on underscores to define the path for each value.","command":"jq 'reduce to_entries[] as $kv ({}; setpath($kv.key|split(\"_\"); $kv.value))'","input_text":"{\"X1_X1o1_X1o1o1\": \"abc\",\"X1_X1o1_X1o1o2\": \"def\",\"X1_X1o2_X1o2o1\": \"ghi\",\"X1_X1o2_X1o2o2\": \"jkl\",\"X1_X1o3\": \"mno\",\"X2\": \"pqr\"}","expected_output":"{\n \"X1\": {\n \"X1o1\": {\n \"X1o1o1\": \"abc\",\n \"X1o1o2\": \"def\"\n },\n \"X1o2\": {\n \"X1o2o1\": \"ghi\",\n \"X1o2o2\": \"jkl\"\n },\n \"X1o3\": \"mno\"\n },\n \"X2\": \"pqr\"\n}\n","validation_input":"{\"a_b_c\": 1,\"a_b_d\": 2,\"a_e\": 3,\"f\": 4}","validation_output":"{\n \"a\": {\n \"b\": {\n \"c\": 1,\n \"d\": 2\n },\n \"e\": 3\n },\n \"f\": 4\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57154970/how-to-get-inverse-operation-of-flatten-for-objects-using-jq","question_title":"How to get inverse operation of flatten for objects using jq?","question_owner":"laracee","answer_owner":"peak","answer_id":57155523,"question_score":7,"reviewed":true,"paraphrase_of":"so-57154970","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-57488844","request":"Remove the 'summary' field from every object in a JSON Lines stream, regardless of nesting depth.","command":"jq -s '[.[] | walk(if type == \"object\" then del(.summary) else . end)][]'","input_text":"{\"object1\": {\"summary\":\"Some summary I want removing\", \"keepMe\":\"please\"}}\n{\"object2\": {\"summary\":\"Delete me too!\", \"keepMe\":\"pretty please\"}}","expected_output":"{\n \"object1\": {\n \"keepMe\": \"please\"\n }\n}\n{\n \"object2\": {\n \"keepMe\": \"pretty please\"\n }\n}\n","validation_input":"{\"a\": {\"summary\": \"x\", \"b\": {\"summary\": \"y\", \"c\": 1}}}\n{\"d\": {\"e\": {\"summary\": \"z\"}, \"f\": 2}}","validation_output":"{\n \"a\": {\n \"b\": {\n \"c\": 1\n }\n }\n}\n{\n \"d\": {\n \"e\": {},\n \"f\": 2\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57488844/deleting-a-field-in-nested-objects-in-jq","question_title":"Deleting a field in nested objects in JQ","question_owner":"Iain Duncan","answer_owner":"peak","answer_id":57489062,"question_score":6,"reviewed":true} {"id":"so-57488844-p1","request":"Strip the 'summary' field from every object within a JSON Lines stream, ensuring removal occurs at any nesting depth.","command":"jq -s '[.[] | walk(if type == \"object\" then del(.summary) else . end)][]'","input_text":"{\"object1\": {\"summary\":\"Some summary I want removing\", \"keepMe\":\"please\"}}\n{\"object2\": {\"summary\":\"Delete me too!\", \"keepMe\":\"pretty please\"}}","expected_output":"{\n \"object1\": {\n \"keepMe\": \"please\"\n }\n}\n{\n \"object2\": {\n \"keepMe\": \"pretty please\"\n }\n}\n","validation_input":"{\"a\": {\"summary\": \"x\", \"b\": {\"summary\": \"y\", \"c\": 1}}}\n{\"d\": {\"e\": {\"summary\": \"z\"}, \"f\": 2}}","validation_output":"{\n \"a\": {\n \"b\": {\n \"c\": 1\n }\n }\n}\n{\n \"d\": {\n \"e\": {},\n \"f\": 2\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57488844/deleting-a-field-in-nested-objects-in-jq","question_title":"Deleting a field in nested objects in JQ","question_owner":"Iain Duncan","answer_owner":"peak","answer_id":57489062,"question_score":6,"reviewed":true,"paraphrase_of":"so-57488844","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-57571424","request":"Extract the 'id' value from the nested 'gecko' object, searching recursively through the JSON structure. If no such 'id' is found, output the string 'error'.","command":"jq -r '(.. | objects | select(has(\"gecko\")) | .gecko.id) // \"error\"'","input_text":"{\n \"browser_specific_settings\": {\n \"gecko\": {\n \"id\": \"{95ad7b39-5d3e-1029-7285-9455bcf665c0}\",\n \"strict_min_version\": \"68.0\"\n }\n }\n}","expected_output":"{95ad7b39-5d3e-1029-7285-9455bcf665c0}\n","validation_input":"{\n \"applications\": {\n \"gecko\": {\n \"id\": \"j30D-3YFPUvj9u9izFoPSjlNYZfF22xS@foobar\",\n \"strict_min_version\": \"53.0\"\n }\n }\n}","validation_output":"j30D-3YFPUvj9u9izFoPSjlNYZfF22xS@foobar\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57571424/ternary-logic-for-returned-value-foo-bar-or-error","question_title":""Ternary logic" for returned value: foo, bar or error","question_owner":"dabbl0r","answer_owner":"oguz ismail","answer_id":57573926,"question_score":6,"reviewed":true} {"id":"so-57571424-p1","request":"Recursively search the JSON structure for an 'id' within a nested 'gecko' object; if found, output the value, otherwise output the string 'error'.","command":"jq -r '(.. | objects | select(has(\"gecko\")) | .gecko.id) // \"error\"'","input_text":"{\n \"browser_specific_settings\": {\n \"gecko\": {\n \"id\": \"{95ad7b39-5d3e-1029-7285-9455bcf665c0}\",\n \"strict_min_version\": \"68.0\"\n }\n }\n}","expected_output":"{95ad7b39-5d3e-1029-7285-9455bcf665c0}\n","validation_input":"{\n \"applications\": {\n \"gecko\": {\n \"id\": \"j30D-3YFPUvj9u9izFoPSjlNYZfF22xS@foobar\",\n \"strict_min_version\": \"53.0\"\n }\n }\n}","validation_output":"j30D-3YFPUvj9u9izFoPSjlNYZfF22xS@foobar\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/57571424/ternary-logic-for-returned-value-foo-bar-or-error","question_title":""Ternary logic" for returned value: foo, bar or error","question_owner":"dabbl0r","answer_owner":"oguz ismail","answer_id":57573926,"question_score":6,"reviewed":true,"paraphrase_of":"so-57571424","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-58239765","request":"Update the 'elements' array in the input JSON. If an element with the name 'foo' exists, change its value to 'BAR'. If no such element exists, append a new object {\"name\": \"foo\", \"value\": \"BAR\"} to the array.","command":"jq '.elements |= (map(.name) | index(\"foo\")) as $ix | if $ix then .[$ix][\"value\"] = \"BAR\" else . + [{name: \"foo\", value: \"BAR\"}] end'","input_text":"{\"elements\": [{\"name\": \"disregard\", \"value\": \"me\"}, {\"name\": \"foo\", \"value\": \"bar\"}, {\"name\": \"dont-edit\", \"value\": \"me\"}]}","expected_output":"{\n \"elements\": [\n {\n \"name\": \"disregard\",\n \"value\": \"me\"\n },\n {\n \"name\": \"foo\",\n \"value\": \"BAR\"\n },\n {\n \"name\": \"dont-edit\",\n \"value\": \"me\"\n }\n ]\n}\n","validation_input":"{\"elements\": [{\"name\": \"other\", \"value\": \"val\"}]}","validation_output":"{\n \"elements\": [\n {\n \"name\": \"other\",\n \"value\": \"val\"\n },\n {\n \"name\": \"foo\",\n \"value\": \"BAR\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58239765/jq-how-to-replace-element-in-an-array-or-add-it-if-it-doesnt-exist","question_title":"jq: How to replace element in an array or add it if it doesn't exist","question_owner":"karstx","answer_owner":"peak","answer_id":58242525,"question_score":5,"reviewed":true} {"id":"so-58239765-p1","request":"Modify the 'elements' array: update the value to 'BAR' if an element named 'foo' exists, or append {\"name\": \"foo\", \"value\": \"BAR\"} if it does not.","command":"jq '.elements |= (map(.name) | index(\"foo\")) as $ix | if $ix then .[$ix][\"value\"] = \"BAR\" else . + [{name: \"foo\", value: \"BAR\"}] end'","input_text":"{\"elements\": [{\"name\": \"disregard\", \"value\": \"me\"}, {\"name\": \"foo\", \"value\": \"bar\"}, {\"name\": \"dont-edit\", \"value\": \"me\"}]}","expected_output":"{\n \"elements\": [\n {\n \"name\": \"disregard\",\n \"value\": \"me\"\n },\n {\n \"name\": \"foo\",\n \"value\": \"BAR\"\n },\n {\n \"name\": \"dont-edit\",\n \"value\": \"me\"\n }\n ]\n}\n","validation_input":"{\"elements\": [{\"name\": \"other\", \"value\": \"val\"}]}","validation_output":"{\n \"elements\": [\n {\n \"name\": \"other\",\n \"value\": \"val\"\n },\n {\n \"name\": \"foo\",\n \"value\": \"BAR\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58239765/jq-how-to-replace-element-in-an-array-or-add-it-if-it-doesnt-exist","question_title":"jq: How to replace element in an array or add it if it doesn't exist","question_owner":"karstx","answer_owner":"peak","answer_id":58242525,"question_score":5,"reviewed":true,"paraphrase_of":"so-58239765","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-58665496","request":"Sort the array within the 'result' key based on the 'value' of the nested tag object where 'key' is 'sequence'.","command":"jq '.result |= sort_by(.tags | from_entries | .sequence)'","input_text":"{\"result\": [{\"name\": \"ct-1\", \"tags\": [{\"key\": \"service_name\", \"value\": \"BaseCT\"}, {\"key\": \"sequence\", \"value\": \"bb\"}]}, {\"name\": \"ct-2\", \"tags\": [{\"key\": \"service_name\", \"value\": \"BaseCT\"}, {\"key\": \"sequence\", \"value\": \"aa\"}]}]}","expected_output":"{\n \"result\": [\n {\n \"name\": \"ct-2\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"BaseCT\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"aa\"\n }\n ]\n },\n {\n \"name\": \"ct-1\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"BaseCT\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"bb\"\n }\n ]\n }\n ]\n}\n","validation_input":"{\"result\": [{\"name\": \"ct-3\", \"tags\": [{\"key\": \"service_name\", \"value\": \"Other\"}, {\"key\": \"sequence\", \"value\": \"cc\"}]}, {\"name\": \"ct-4\", \"tags\": [{\"key\": \"service_name\", \"value\": \"Other\"}, {\"key\": \"sequence\", \"value\": \"aa\"}]}]}","validation_output":"{\n \"result\": [\n {\n \"name\": \"ct-4\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"Other\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"aa\"\n }\n ]\n },\n {\n \"name\": \"ct-3\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"Other\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"cc\"\n }\n ]\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58665496/jq-sort-using-the-value-of-a-nested-array-element","question_title":"jq sort using the value of a nested array element","question_owner":"Sanjay Saxena","answer_owner":"oguz ismail","answer_id":58665725,"question_score":6,"reviewed":true} {"id":"so-58665496-p1","request":"Sort the array located at the 'result' key based on the 'value' of the nested tag object where the 'key' equals 'sequence'.","command":"jq '.result |= sort_by(.tags | from_entries | .sequence)'","input_text":"{\"result\": [{\"name\": \"ct-1\", \"tags\": [{\"key\": \"service_name\", \"value\": \"BaseCT\"}, {\"key\": \"sequence\", \"value\": \"bb\"}]}, {\"name\": \"ct-2\", \"tags\": [{\"key\": \"service_name\", \"value\": \"BaseCT\"}, {\"key\": \"sequence\", \"value\": \"aa\"}]}]}","expected_output":"{\n \"result\": [\n {\n \"name\": \"ct-2\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"BaseCT\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"aa\"\n }\n ]\n },\n {\n \"name\": \"ct-1\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"BaseCT\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"bb\"\n }\n ]\n }\n ]\n}\n","validation_input":"{\"result\": [{\"name\": \"ct-3\", \"tags\": [{\"key\": \"service_name\", \"value\": \"Other\"}, {\"key\": \"sequence\", \"value\": \"cc\"}]}, {\"name\": \"ct-4\", \"tags\": [{\"key\": \"service_name\", \"value\": \"Other\"}, {\"key\": \"sequence\", \"value\": \"aa\"}]}]}","validation_output":"{\n \"result\": [\n {\n \"name\": \"ct-4\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"Other\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"aa\"\n }\n ]\n },\n {\n \"name\": \"ct-3\",\n \"tags\": [\n {\n \"key\": \"service_name\",\n \"value\": \"Other\"\n },\n {\n \"key\": \"sequence\",\n \"value\": \"cc\"\n }\n ]\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58665496/jq-sort-using-the-value-of-a-nested-array-element","question_title":"jq sort using the value of a nested array element","question_owner":"Sanjay Saxena","answer_owner":"oguz ismail","answer_id":58665725,"question_score":6,"reviewed":true,"paraphrase_of":"so-58665496","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-58917592","request":"Calculate the sum of the 'qty' field for all objects in the 'objects' array.","command":"jq '.objects | map(.qty) | add'","input_text":"{\"product\":\"BIG MAC\",\"objects\":[{\"qty\":10,\"size\":32},{\"qty\":20,\"size\":53},{\"qty\":10,\"size\":54}]}","expected_output":"40\n","validation_input":"{\"product\":\"WHOPPER\",\"objects\":[{\"qty\":5,\"size\":10},{\"qty\":15,\"size\":20}]}","validation_output":"20\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58917592/need-help-in-reducing-array-of-object-into-a-single-sum","question_title":"Need help in reducing array of object into a single sum","question_owner":"uday8486","answer_owner":"chepner","answer_id":58917813,"question_score":5,"reviewed":true} {"id":"so-58917592-p1","request":"Compute the total sum of the 'qty' field across all objects in the 'objects' array.","command":"jq '.objects | map(.qty) | add'","input_text":"{\"product\":\"BIG MAC\",\"objects\":[{\"qty\":10,\"size\":32},{\"qty\":20,\"size\":53},{\"qty\":10,\"size\":54}]}","expected_output":"40\n","validation_input":"{\"product\":\"WHOPPER\",\"objects\":[{\"qty\":5,\"size\":10},{\"qty\":15,\"size\":20}]}","validation_output":"20\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/58917592/need-help-in-reducing-array-of-object-into-a-single-sum","question_title":"Need help in reducing array of object into a single sum","question_owner":"uday8486","answer_owner":"chepner","answer_id":58917813,"question_score":5,"reviewed":true,"paraphrase_of":"so-58917592","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-59063536","request":"Round the 'mass' value to the nearest integer using standard rounding rules (half-up).","command":"jq '.mass + 0.5 | floor'","input_text":"{\"mass\": 188.72}\n","expected_output":"189\n","validation_input":"{\"mass\": 5.52}\n","validation_output":"6\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59063536/how-to-round-floor-ceil-truncate","question_title":"How to round, floor, ceil, truncate","question_owner":"jmpsabisb","answer_owner":"oguz ismail","answer_id":59063940,"question_score":5,"reviewed":true} {"id":"so-59063536-p1","request":"Round the 'mass' value to the nearest integer using standard half-up rounding rules.","command":"jq '.mass + 0.5 | floor'","input_text":"{\"mass\": 188.72}\n","expected_output":"189\n","validation_input":"{\"mass\": 5.52}\n","validation_output":"6\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59063536/how-to-round-floor-ceil-truncate","question_title":"How to round, floor, ceil, truncate","question_owner":"jmpsabisb","answer_owner":"oguz ismail","answer_id":59063940,"question_score":5,"reviewed":true,"paraphrase_of":"so-59063536","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-59551206","request":"Read a JSON array of user objects from stdin. For each user, output a raw string in the format: Email address for user [first_name] [last_name] is \"[email]\".","command":"jq -r '.[] | \"Email address for user \\(.first_name) \\(.last_name) is \\\"\\(.email)\\\"\"'","input_text":"[{\"first_name\": \"Angela\", \"last_name\": \"Sleney\", \"email\": \"asleney0@nytimes.com\"}, {\"first_name\": \"Clint\", \"last_name\": \"Ducroe\", \"email\": \"cducroe1@aboutads.info\"}]","expected_output":"Email address for user Angela Sleney is \"asleney0@nytimes.com\"\nEmail address for user Clint Ducroe is \"cducroe1@aboutads.info\"\n","validation_input":"[{\"first_name\": \"John\", \"last_name\": \"Doe\", \"email\": \"john@example.com\"}]","validation_output":"Email address for user John Doe is \"john@example.com\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59551206/how-can-i-print-an-arbitrary-string-with-jq","question_title":"How can I print an arbitrary string with JQ?","question_owner":"Gruber","answer_owner":"Rohit Mishra","answer_id":59551309,"question_score":6,"reviewed":true} {"id":"so-59551206-p1","request":"Process a JSON array of user objects from stdin and output a raw string for each in the format: Email address for user [first_name] [last_name] is \"[email]\".","command":"jq -r '.[] | \"Email address for user \\(.first_name) \\(.last_name) is \\\"\\(.email)\\\"\"'","input_text":"[{\"first_name\": \"Angela\", \"last_name\": \"Sleney\", \"email\": \"asleney0@nytimes.com\"}, {\"first_name\": \"Clint\", \"last_name\": \"Ducroe\", \"email\": \"cducroe1@aboutads.info\"}]","expected_output":"Email address for user Angela Sleney is \"asleney0@nytimes.com\"\nEmail address for user Clint Ducroe is \"cducroe1@aboutads.info\"\n","validation_input":"[{\"first_name\": \"John\", \"last_name\": \"Doe\", \"email\": \"john@example.com\"}]","validation_output":"Email address for user John Doe is \"john@example.com\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59551206/how-can-i-print-an-arbitrary-string-with-jq","question_title":"How can I print an arbitrary string with JQ?","question_owner":"Gruber","answer_owner":"Rohit Mishra","answer_id":59551309,"question_score":6,"reviewed":true,"paraphrase_of":"so-59551206","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-59778708","request":"Recursively traverse the input JSON to find all leaf values that are not objects. For each leaf, output a CSV row containing the path to that value followed by the string representation of the value.","command":"jq -r '[paths(scalars) as $p | $p + [getpath($p) | tostring]] | .[] | @csv'","input_text":"{\"items\": [{\"id\": 1234, \"title\": \"Title\", \"internet\": {\"favicon\": \"https://example.com/icon.png\", \"domain\": \"https://example.com\"}, \"url\": \"https://example.com/image.png?version=1\"}], \"other\": {\"data\": 0, \"notes\": 1}}","expected_output":"\"items\",0,\"id\",\"1234\"\n\"items\",0,\"title\",\"Title\"\n\"items\",0,\"internet\",\"favicon\",\"https://example.com/icon.png\"\n\"items\",0,\"internet\",\"domain\",\"https://example.com\"\n\"items\",0,\"url\",\"https://example.com/image.png?version=1\"\n\"other\",\"data\",\"0\"\n\"other\",\"notes\",\"1\"\n","validation_input":"{\"a\": {\"b\": 1, \"c\": \"text\"}, \"d\": null}","validation_output":"\"a\",\"b\",\"1\"\n\"a\",\"c\",\"text\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59778708/jq-error-object-is-not-valid-in-a-csv-row","question_title":"jq error "object is not valid in a csv row"","question_owner":"l'L'l","answer_owner":"peak","answer_id":59801016,"question_score":6,"reviewed":true} {"id":"so-59778708-p1","request":"Traverse the input JSON recursively to locate all non-object leaf values, outputting a CSV row for each that includes the value's path and its string representation.","command":"jq -r '[paths(scalars) as $p | $p + [getpath($p) | tostring]] | .[] | @csv'","input_text":"{\"items\": [{\"id\": 1234, \"title\": \"Title\", \"internet\": {\"favicon\": \"https://example.com/icon.png\", \"domain\": \"https://example.com\"}, \"url\": \"https://example.com/image.png?version=1\"}], \"other\": {\"data\": 0, \"notes\": 1}}","expected_output":"\"items\",0,\"id\",\"1234\"\n\"items\",0,\"title\",\"Title\"\n\"items\",0,\"internet\",\"favicon\",\"https://example.com/icon.png\"\n\"items\",0,\"internet\",\"domain\",\"https://example.com\"\n\"items\",0,\"url\",\"https://example.com/image.png?version=1\"\n\"other\",\"data\",\"0\"\n\"other\",\"notes\",\"1\"\n","validation_input":"{\"a\": {\"b\": 1, \"c\": \"text\"}, \"d\": null}","validation_output":"\"a\",\"b\",\"1\"\n\"a\",\"c\",\"text\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/59778708/jq-error-object-is-not-valid-in-a-csv-row","question_title":"jq error "object is not valid in a csv row"","question_owner":"l'L'l","answer_owner":"peak","answer_id":59801016,"question_score":6,"reviewed":true,"paraphrase_of":"so-59778708","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-60011507","request":"Group the input array of objects by the 'clusterName' field. For each group, create an object containing the 'clusterName' and a 'buckets' array consisting of objects with only the 'name' field from the original items.","command":"jq '[group_by(.clusterName)[] | {clusterName: .[0].clusterName, buckets: [.[] | {name: .name}]}]'","input_text":"[{\"name\": \"bucket1\",\"clusterName\":\"cluster1\"},{\"name\": \"bucket2\",\"clusterName\":\"cluster1\"},{\"name\": \"bucket3\",\"clusterName\":\"cluster2\"},{\"name\": \"bucket4\",\"clusterName\":\"cluster2\"}]","expected_output":"[\n {\n \"clusterName\": \"cluster1\",\n \"buckets\": [\n {\n \"name\": \"bucket1\"\n },\n {\n \"name\": \"bucket2\"\n }\n ]\n },\n {\n \"clusterName\": \"cluster2\",\n \"buckets\": [\n {\n \"name\": \"bucket3\"\n },\n {\n \"name\": \"bucket4\"\n }\n ]\n }\n]\n","validation_input":"[{\"name\": \"alpha\",\"clusterName\":\"grpA\"},{\"name\": \"beta\",\"clusterName\":\"grpB\"},{\"name\": \"gamma\",\"clusterName\":\"grpA\"}]","validation_output":"[\n {\n \"clusterName\": \"grpA\",\n \"buckets\": [\n {\n \"name\": \"alpha\"\n },\n {\n \"name\": \"gamma\"\n }\n ]\n },\n {\n \"clusterName\": \"grpB\",\n \"buckets\": [\n {\n \"name\": \"beta\"\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60011507/how-to-group-by-in-jq","question_title":"How to group by in jq?","question_owner":"developthou","answer_owner":"Torben Pi Jensen","answer_id":60011871,"question_score":7,"reviewed":true} {"id":"so-60011507-p1","request":"Group the input array of objects by 'clusterName', creating an object for each group that contains the 'clusterName' and a 'buckets' array of objects holding only the original items' 'name' fields.","command":"jq '[group_by(.clusterName)[] | {clusterName: .[0].clusterName, buckets: [.[] | {name: .name}]}]'","input_text":"[{\"name\": \"bucket1\",\"clusterName\":\"cluster1\"},{\"name\": \"bucket2\",\"clusterName\":\"cluster1\"},{\"name\": \"bucket3\",\"clusterName\":\"cluster2\"},{\"name\": \"bucket4\",\"clusterName\":\"cluster2\"}]","expected_output":"[\n {\n \"clusterName\": \"cluster1\",\n \"buckets\": [\n {\n \"name\": \"bucket1\"\n },\n {\n \"name\": \"bucket2\"\n }\n ]\n },\n {\n \"clusterName\": \"cluster2\",\n \"buckets\": [\n {\n \"name\": \"bucket3\"\n },\n {\n \"name\": \"bucket4\"\n }\n ]\n }\n]\n","validation_input":"[{\"name\": \"alpha\",\"clusterName\":\"grpA\"},{\"name\": \"beta\",\"clusterName\":\"grpB\"},{\"name\": \"gamma\",\"clusterName\":\"grpA\"}]","validation_output":"[\n {\n \"clusterName\": \"grpA\",\n \"buckets\": [\n {\n \"name\": \"alpha\"\n },\n {\n \"name\": \"gamma\"\n }\n ]\n },\n {\n \"clusterName\": \"grpB\",\n \"buckets\": [\n {\n \"name\": \"beta\"\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60011507/how-to-group-by-in-jq","question_title":"How to group by in jq?","question_owner":"developthou","answer_owner":"Torben Pi Jensen","answer_id":60011871,"question_score":7,"reviewed":true,"paraphrase_of":"so-60011507","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-60460376","request":"Calculate the average of the 'p80' values found in the 'ExtendedStatistics' object within each item of the 'Datapoints' array, filtering for values greater than or equal to 0.","command":"jq '[.Datapoints[] | select(.ExtendedStatistics.p80 >= 0) | .ExtendedStatistics.p80] | add / length'","input_text":"{\"Label\": \"CPUUtilization\", \"Datapoints\": [{\"Timestamp\": \"2020-02-20T18:35:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 7.39284928374}}, {\"Timestamp\": \"2020-02-20T18:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.234234}}, {\"Timestamp\": \"2020-02-20T18:45:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.4567}}, {\"Timestamp\": \"2020-02-20T18:50:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.0}}, {\"Timestamp\": \"2020-02-20T18:20:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.0}}]}","expected_output":"3.2167566567479993\n","validation_input":"{\"Label\": \"Test\", \"Datapoints\": [{\"Timestamp\": \"2020-01-01T00:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 10.0}}, {\"Timestamp\": \"2020-01-01T01:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 20.0}}]}","validation_output":"15\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60460376/how-to-calculate-average-using-jq-from-json-output","question_title":"How to calculate average using jq from JSON output","question_owner":"novice sysadmin","answer_owner":"Poshi","answer_id":60460606,"question_score":7,"reviewed":true} {"id":"so-60460376-p1","request":"Compute the mean of 'p80' entries within the 'ExtendedStatistics' of every element in the 'Datapoints' list, considering only those values that are 0 or higher.","command":"jq '[.Datapoints[] | select(.ExtendedStatistics.p80 >= 0) | .ExtendedStatistics.p80] | add / length'","input_text":"{\"Label\": \"CPUUtilization\", \"Datapoints\": [{\"Timestamp\": \"2020-02-20T18:35:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 7.39284928374}}, {\"Timestamp\": \"2020-02-20T18:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.234234}}, {\"Timestamp\": \"2020-02-20T18:45:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.4567}}, {\"Timestamp\": \"2020-02-20T18:50:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.0}}, {\"Timestamp\": \"2020-02-20T18:20:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 2.0}}]}","expected_output":"3.2167566567479993\n","validation_input":"{\"Label\": \"Test\", \"Datapoints\": [{\"Timestamp\": \"2020-01-01T00:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 10.0}}, {\"Timestamp\": \"2020-01-01T01:00:00Z\", \"Unit\": \"Percent\", \"ExtendedStatistics\": {\"p80\": 20.0}}]}","validation_output":"15\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60460376/how-to-calculate-average-using-jq-from-json-output","question_title":"How to calculate average using jq from JSON output","question_owner":"novice sysadmin","answer_owner":"Poshi","answer_id":60460606,"question_score":7,"reviewed":true,"paraphrase_of":"so-60460376","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-60609883","request":"Replace all boolean values in a JSON structure with 1 if true and 0 if false, preserving the original structure.","command":"jq '(.. | select(type == \"boolean\")) |= if . then 1 else 0 end'","input_text":"[true, false, [5, true, [true, [false]], false]]","expected_output":"[\n 1,\n 0,\n [\n 5,\n 1,\n [\n 1,\n [\n 0\n ]\n ],\n 0\n ]\n]\n","validation_input":"[[true, [false]], {\"a\": true, \"b\": [false, 1]}]","validation_output":"[\n [\n 1,\n [\n 0\n ]\n ],\n {\n \"a\": 1,\n \"b\": [\n 0,\n 1\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60609883/jq-how-operator-works","question_title":"jq - how |= operator works?","question_owner":"mon","answer_owner":"chepner","answer_id":60609987,"question_score":6,"reviewed":true} {"id":"so-60609883-p1","request":"Transform all boolean literals in a JSON document to integers, mapping true to 1 and false to 0, while keeping the rest of the structure intact.","command":"jq '(.. | select(type == \"boolean\")) |= if . then 1 else 0 end'","input_text":"[true, false, [5, true, [true, [false]], false]]","expected_output":"[\n 1,\n 0,\n [\n 5,\n 1,\n [\n 1,\n [\n 0\n ]\n ],\n 0\n ]\n]\n","validation_input":"[[true, [false]], {\"a\": true, \"b\": [false, 1]}]","validation_output":"[\n [\n 1,\n [\n 0\n ]\n ],\n {\n \"a\": 1,\n \"b\": [\n 0,\n 1\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60609883/jq-how-operator-works","question_title":"jq - how |= operator works?","question_owner":"mon","answer_owner":"chepner","answer_id":60609987,"question_score":6,"reviewed":true,"paraphrase_of":"so-60609883","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-60637859","request":"Convert a sequence of JSON lines (JSONL) into a single JSON array.","command":"jq -s '.'","input_text":"{\"address\":\"email1@foo.bar.com\", \"topic\":\"Some topic.\"}\n{\"address\":\"email2@foo.bar.com\", \"topic\":\"Another topic.\"}\n{\"address\":\"email3@foo.bar.com\", \"topic\":\"Yet another topic.\"}","expected_output":"[\n {\n \"address\": \"email1@foo.bar.com\",\n \"topic\": \"Some topic.\"\n },\n {\n \"address\": \"email2@foo.bar.com\",\n \"topic\": \"Another topic.\"\n },\n {\n \"address\": \"email3@foo.bar.com\",\n \"topic\": \"Yet another topic.\"\n }\n]\n","validation_input":"{\"id\":1, \"val\":\"a\"}\n{\"id\":2, \"val\":\"b\"}","validation_output":"[\n {\n \"id\": 1,\n \"val\": \"a\"\n },\n {\n \"id\": 2,\n \"val\": \"b\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60637859/convert-sequence-of-json-lines-jsonl-to-json-array","question_title":"Convert sequence of JSON lines (JSONL) to JSON array","question_owner":"km1","answer_owner":"Charles Duffy","answer_id":60639286,"question_score":8,"reviewed":true} {"id":"so-60637859-p1","request":"Transform a JSON Lines (JSONL) stream into a single consolidated JSON array.","command":"jq -s '.'","input_text":"{\"address\":\"email1@foo.bar.com\", \"topic\":\"Some topic.\"}\n{\"address\":\"email2@foo.bar.com\", \"topic\":\"Another topic.\"}\n{\"address\":\"email3@foo.bar.com\", \"topic\":\"Yet another topic.\"}","expected_output":"[\n {\n \"address\": \"email1@foo.bar.com\",\n \"topic\": \"Some topic.\"\n },\n {\n \"address\": \"email2@foo.bar.com\",\n \"topic\": \"Another topic.\"\n },\n {\n \"address\": \"email3@foo.bar.com\",\n \"topic\": \"Yet another topic.\"\n }\n]\n","validation_input":"{\"id\":1, \"val\":\"a\"}\n{\"id\":2, \"val\":\"b\"}","validation_output":"[\n {\n \"id\": 1,\n \"val\": \"a\"\n },\n {\n \"id\": 2,\n \"val\": \"b\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60637859/convert-sequence-of-json-lines-jsonl-to-json-array","question_title":"Convert sequence of JSON lines (JSONL) to JSON array","question_owner":"km1","answer_owner":"Charles Duffy","answer_id":60639286,"question_score":8,"reviewed":true,"paraphrase_of":"so-60637859","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-60865446","request":"Replace the first occurrence of the letter 'b' with 'f' in each string in the input stream.","command":"jq -r 'sub(\"b\"; \"f\")'","input_text":"\"bar\"\n\"baz\"","expected_output":"far\nfaz\n","validation_input":"\"banana\"\n\"blueberry\"","validation_output":"fanana\nflueberry\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60865446/using-sub-in-jq-v1-6-errors-in-sub-is-not-defined","question_title":"Using "sub()" in jq v1.6 errors in "sub is not defined"","question_owner":"Lukas Grebe","answer_owner":"Inian","answer_id":60865506,"question_score":6,"reviewed":true} {"id":"so-60865446-p1","request":"For every string in the input, substitute the initial instance of the character 'b' with 'f'.","command":"jq -r 'sub(\"b\"; \"f\")'","input_text":"\"bar\"\n\"baz\"","expected_output":"far\nfaz\n","validation_input":"\"banana\"\n\"blueberry\"","validation_output":"fanana\nflueberry\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/60865446/using-sub-in-jq-v1-6-errors-in-sub-is-not-defined","question_title":"Using "sub()" in jq v1.6 errors in "sub is not defined"","question_owner":"Lukas Grebe","answer_owner":"Inian","answer_id":60865506,"question_score":6,"reviewed":true,"paraphrase_of":"so-60865446","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-61012699","request":"Format the Start_Date, Function_Start_Date, and Date_of_Birth fields in each object of the input JSON array from YYYYMMDD to YYYY-MM-DD format.","command":"jq '[.[] | .Start_Date |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\" | .Function_Start_Date |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\" | .Date_of_Birth |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\"]'","input_text":"[\n {\n \"Mail\": \"john@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000555\",\n \"First_Name\": \"John\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"19770516\",\n \"Function_Start_Date\": \"19770516\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Operations Manager Warehousing\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19560719\",\n \"Gender\": \"1\"\n },\n {\n \"Mail\": \"mary@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000777\",\n \"First_Name\": \"Mary\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"19800101\",\n \"Function_Start_Date\": \"19800101\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Manager\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19601225\",\n \"Gender\": \"2\"\n }\n]","expected_output":"[\n {\n \"Mail\": \"john@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000555\",\n \"First_Name\": \"John\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"1977-05-16\",\n \"Function_Start_Date\": \"1977-05-16\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Operations Manager Warehousing\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1956-07-19\",\n \"Gender\": \"1\"\n },\n {\n \"Mail\": \"mary@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000777\",\n \"First_Name\": \"Mary\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"1980-01-01\",\n \"Function_Start_Date\": \"1980-01-01\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Manager\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1960-12-25\",\n \"Gender\": \"2\"\n }\n]\n","validation_input":"[\n {\n \"Mail\": \"alice@example.com\",\n \"Name\": \"Doe\",\n \"Employee_Number\": \"000111\",\n \"First_Name\": \"Alice\",\n \"Company\": \"Corp\",\n \"Department\": \"IT\",\n \"Employment_Status\": \"Active\",\n \"Start_Date\": \"20230510\",\n \"Function_Start_Date\": \"20230510\",\n \"Group_Phone\": \"123\",\n \"Job_Title\": \"Dev\",\n \"Sub_Group\": \"Tech\",\n \"Location\": \"NYC\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19900101\",\n \"Gender\": \"1\"\n }\n]","validation_output":"[\n {\n \"Mail\": \"alice@example.com\",\n \"Name\": \"Doe\",\n \"Employee_Number\": \"000111\",\n \"First_Name\": \"Alice\",\n \"Company\": \"Corp\",\n \"Department\": \"IT\",\n \"Employment_Status\": \"Active\",\n \"Start_Date\": \"2023-05-10\",\n \"Function_Start_Date\": \"2023-05-10\",\n \"Group_Phone\": \"123\",\n \"Job_Title\": \"Dev\",\n \"Sub_Group\": \"Tech\",\n \"Location\": \"NYC\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1990-01-01\",\n \"Gender\": \"1\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61012699/jq-substr-equivalent-to-format-a-value","question_title":"jq substr() equivalent to format a value","question_owner":"Wil","answer_owner":"oguz ismail","answer_id":61012765,"question_score":6,"reviewed":true} {"id":"so-61012699-p1","request":"Reformat the 'Start_Date', 'Function_Start_Date', and 'Date_of_Birth' attributes in each object of the provided JSON array from YYYYMMDD to YYYY-MM-DD.","command":"jq '[.[] | .Start_Date |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\" | .Function_Start_Date |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\" | .Date_of_Birth |= \"\\(.[0:4])-\\(.[4:6])-\\(.[6:8])\"]'","input_text":"[\n {\n \"Mail\": \"john@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000555\",\n \"First_Name\": \"John\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"19770516\",\n \"Function_Start_Date\": \"19770516\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Operations Manager Warehousing\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19560719\",\n \"Gender\": \"1\"\n },\n {\n \"Mail\": \"mary@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000777\",\n \"First_Name\": \"Mary\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"19800101\",\n \"Function_Start_Date\": \"19800101\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Manager\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19601225\",\n \"Gender\": \"2\"\n }\n]","expected_output":"[\n {\n \"Mail\": \"john@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000555\",\n \"First_Name\": \"John\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"1977-05-16\",\n \"Function_Start_Date\": \"1977-05-16\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Operations Manager Warehousing\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1956-07-19\",\n \"Gender\": \"1\"\n },\n {\n \"Mail\": \"mary@example.com\",\n \"Name\": \"Smith\",\n \"Employee_Number\": \"000777\",\n \"First_Name\": \"Mary\",\n \"Company\": \"ACME\",\n \"Department\": null,\n \"Employment_Status\": \"Retiree\",\n \"Start_Date\": \"1980-01-01\",\n \"Function_Start_Date\": \"1980-01-01\",\n \"Group_Phone\": \"\",\n \"Job_Title\": \"Manager\",\n \"Sub_Group\": \"Exempts\",\n \"Location\": \"Tibuktu\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1960-12-25\",\n \"Gender\": \"2\"\n }\n]\n","validation_input":"[\n {\n \"Mail\": \"alice@example.com\",\n \"Name\": \"Doe\",\n \"Employee_Number\": \"000111\",\n \"First_Name\": \"Alice\",\n \"Company\": \"Corp\",\n \"Department\": \"IT\",\n \"Employment_Status\": \"Active\",\n \"Start_Date\": \"20230510\",\n \"Function_Start_Date\": \"20230510\",\n \"Group_Phone\": \"123\",\n \"Job_Title\": \"Dev\",\n \"Sub_Group\": \"Tech\",\n \"Location\": \"NYC\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"19900101\",\n \"Gender\": \"1\"\n }\n]","validation_output":"[\n {\n \"Mail\": \"alice@example.com\",\n \"Name\": \"Doe\",\n \"Employee_Number\": \"000111\",\n \"First_Name\": \"Alice\",\n \"Company\": \"Corp\",\n \"Department\": \"IT\",\n \"Employment_Status\": \"Active\",\n \"Start_Date\": \"2023-05-10\",\n \"Function_Start_Date\": \"2023-05-10\",\n \"Group_Phone\": \"123\",\n \"Job_Title\": \"Dev\",\n \"Sub_Group\": \"Tech\",\n \"Location\": \"NYC\",\n \"Organizational_Unit\": null,\n \"Date_of_Birth\": \"1990-01-01\",\n \"Gender\": \"1\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61012699/jq-substr-equivalent-to-format-a-value","question_title":"jq substr() equivalent to format a value","question_owner":"Wil","answer_owner":"oguz ismail","answer_id":61012765,"question_score":6,"reviewed":true,"paraphrase_of":"so-61012699","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-61101083","request":"Extract the last key-value pair from the input JSON object and return it as a new JSON object containing only that pair.","command":"jq 'to_entries | [last] | from_entries'","input_text":"{\"1\": {\"a\": \"1\"}, \"2\": {\"a\": \"2\"}, \"3\": {\"a\": \"3\"}}","expected_output":"{\n \"3\": {\n \"a\": \"3\"\n }\n}\n","validation_input":"{\"x\": 10, \"y\": 20, \"z\": 30}","validation_output":"{\n \"z\": 30\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61101083/jq-how-to-get-the-last-entry-in-an-object","question_title":"jq how to get the last entry in an object","question_owner":"Timm","answer_owner":"Aaron","answer_id":61101243,"question_score":5,"reviewed":true} {"id":"so-61101083-p1","request":"Isolate the final key-value pair from the source JSON object and output it as a standalone JSON object.","command":"jq 'to_entries | [last] | from_entries'","input_text":"{\"1\": {\"a\": \"1\"}, \"2\": {\"a\": \"2\"}, \"3\": {\"a\": \"3\"}}","expected_output":"{\n \"3\": {\n \"a\": \"3\"\n }\n}\n","validation_input":"{\"x\": 10, \"y\": 20, \"z\": 30}","validation_output":"{\n \"z\": 30\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61101083/jq-how-to-get-the-last-entry-in-an-object","question_title":"jq how to get the last entry in an object","question_owner":"Timm","answer_owner":"Aaron","answer_id":61101243,"question_score":5,"reviewed":true,"paraphrase_of":"so-61101083","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-61779277","request":"Extract all values from the nested object located at .images.tags and output them as raw strings, one per line.","command":"jq -r '.images.tags[]'","input_text":"{\n \"images\": {\n \"tags\": {\n \"one\": \"abc:v0.3-16-07\",\n \"two\": \"xyz:ng-0.23.0\",\n \"pq\": \"qaa:0df1e21e752b3d3.2020-04-27_1\"\n }\n }\n}","expected_output":"abc:v0.3-16-07\nxyz:ng-0.23.0\nqaa:0df1e21e752b3d3.2020-04-27_1\n","validation_input":"{\n \"images\": {\n \"tags\": {\n \"alpha\": \"img1:latest\",\n \"beta\": \"img2:v1.0\"\n }\n }\n}","validation_output":"img1:latest\nimg2:v1.0\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61779277/yq-to-get-values-from-key-value-pair","question_title":"yq to get values from key value pair","question_owner":"Saurabh Arora","answer_owner":"Inian","answer_id":61780374,"question_score":9,"reviewed":true} {"id":"so-61779277-p1","request":"Retrieve all values from the nested structure at .images.tags and print them as plain text strings, with each value on a new line.","command":"jq -r '.images.tags[]'","input_text":"{\n \"images\": {\n \"tags\": {\n \"one\": \"abc:v0.3-16-07\",\n \"two\": \"xyz:ng-0.23.0\",\n \"pq\": \"qaa:0df1e21e752b3d3.2020-04-27_1\"\n }\n }\n}","expected_output":"abc:v0.3-16-07\nxyz:ng-0.23.0\nqaa:0df1e21e752b3d3.2020-04-27_1\n","validation_input":"{\n \"images\": {\n \"tags\": {\n \"alpha\": \"img1:latest\",\n \"beta\": \"img2:v1.0\"\n }\n }\n}","validation_output":"img1:latest\nimg2:v1.0\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/61779277/yq-to-get-values-from-key-value-pair","question_title":"yq to get values from key value pair","question_owner":"Saurabh Arora","answer_owner":"Inian","answer_id":61780374,"question_score":9,"reviewed":true,"paraphrase_of":"so-61779277","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-62031471","request":"Extract the key name from a JSON object where the nested value has a 'primary' field set to true.","command":"jq -r 'to_entries | map(select(.value.primary) | .key)[0]'","input_text":"{\"foo\": {\"primary\": true, \"blah\": \"beep\"}, \"bar\": {\"primary\": false, \"blah\": \"narf\"}, \"baz\": {\"primary\": false, \"blah\": \"poink\"}}","expected_output":"foo\n","validation_input":"{\"x\": {\"primary\": false, \"val\": 1}, \"y\": {\"primary\": true, \"val\": 2}, \"z\": {\"primary\": false, \"val\": 3}}","validation_output":"y\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/62031471/how-do-i-extract-a-key-with-jq-based-on-its-child-values","question_title":"How do I extract a key with jq based on its child values","question_owner":"Crell","answer_owner":"customcommander","answer_id":62031684,"question_score":7,"reviewed":true} {"id":"so-62031471-p1","request":"Identify and return the key name from a JSON object where the nested value contains a 'primary' field equal to true.","command":"jq -r 'to_entries | map(select(.value.primary) | .key)[0]'","input_text":"{\"foo\": {\"primary\": true, \"blah\": \"beep\"}, \"bar\": {\"primary\": false, \"blah\": \"narf\"}, \"baz\": {\"primary\": false, \"blah\": \"poink\"}}","expected_output":"foo\n","validation_input":"{\"x\": {\"primary\": false, \"val\": 1}, \"y\": {\"primary\": true, \"val\": 2}, \"z\": {\"primary\": false, \"val\": 3}}","validation_output":"y\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/62031471/how-do-i-extract-a-key-with-jq-based-on-its-child-values","question_title":"How do I extract a key with jq based on its child values","question_owner":"Crell","answer_owner":"customcommander","answer_id":62031684,"question_score":7,"reviewed":true,"paraphrase_of":"so-62031471","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-62454640","request":"Lowercase the value of the 'Id' field for every object in the input array.","command":"jq '[.[] | .Id |= ascii_downcase]'","input_text":"[\n {\n \"Id\": \"ABC123\",\n \"Name\": \"Item 1\"\n },\n {\n \"Id\": \"XYZ789\",\n \"Name\": \"Item 2\"\n }\n]","expected_output":"[\n {\n \"Id\": \"abc123\",\n \"Name\": \"Item 1\"\n },\n {\n \"Id\": \"xyz789\",\n \"Name\": \"Item 2\"\n }\n]\n","validation_input":"[\n {\n \"Id\": \"HelloWorld\",\n \"Value\": 10\n },\n {\n \"Id\": \"TestString\",\n \"Value\": 20\n }\n]","validation_output":"[\n {\n \"Id\": \"helloworld\",\n \"Value\": 10\n },\n {\n \"Id\": \"teststring\",\n \"Value\": 20\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/62454640/downcase-a-value-in-json","question_title":"downcase a value in JSON","question_owner":"Tony","answer_owner":"oguz ismail","answer_id":62454688,"question_score":7,"reviewed":true} {"id":"so-62454640-p1","request":"Convert the 'Id' field value to lowercase for each object within the input array.","command":"jq '[.[] | .Id |= ascii_downcase]'","input_text":"[\n {\n \"Id\": \"ABC123\",\n \"Name\": \"Item 1\"\n },\n {\n \"Id\": \"XYZ789\",\n \"Name\": \"Item 2\"\n }\n]","expected_output":"[\n {\n \"Id\": \"abc123\",\n \"Name\": \"Item 1\"\n },\n {\n \"Id\": \"xyz789\",\n \"Name\": \"Item 2\"\n }\n]\n","validation_input":"[\n {\n \"Id\": \"HelloWorld\",\n \"Value\": 10\n },\n {\n \"Id\": \"TestString\",\n \"Value\": 20\n }\n]","validation_output":"[\n {\n \"Id\": \"helloworld\",\n \"Value\": 10\n },\n {\n \"Id\": \"teststring\",\n \"Value\": 20\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/62454640/downcase-a-value-in-json","question_title":"downcase a value in JSON","question_owner":"Tony","answer_owner":"oguz ismail","answer_id":62454688,"question_score":7,"reviewed":true,"paraphrase_of":"so-62454640","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-63126834","request":"Sort the array of pull requests by their key field.","command":"jq '.pullRequests | sort_by(.key)'","input_text":"{\"pullRequests\": [{\"key\": \"11346\", \"title\": \"feature/XXX-Validation\", \"branch\": \"feature/XXX-Validation\", \"base\": \"develop\", \"status\": {\"qualityGateStatus\": \"OK\", \"bugs\": 0, \"vulnerabilities\": 0, \"codeSmells\": 1}, \"analysisDate\": \"2020-07-27T14:22:36+0000\", \"url\": \"https://abc/org/_git/repo/pullrequest/11346\", \"target\": \"develop\"}, {\"key\": \"11151\", \"title\": \"feature/xxx-data\", \"branch\": \"feature/xxx-data\", \"base\": \"develop\", \"status\": {\"qualityGateStatus\": \"OK\", \"bugs\": 0, \"vulnerabilities\": 0, \"codeSmells\": 0}, \"analysisDate\": \"2020-07-22T11:11:11+0000\", \"url\": \"https://abc/org/_git/repo/pullrequest/11151\", \"target\": \"develop\"}]}","expected_output":"[\n {\n \"key\": \"11151\",\n \"title\": \"feature/xxx-data\",\n \"branch\": \"feature/xxx-data\",\n \"base\": \"develop\",\n \"status\": {\n \"qualityGateStatus\": \"OK\",\n \"bugs\": 0,\n \"vulnerabilities\": 0,\n \"codeSmells\": 0\n },\n \"analysisDate\": \"2020-07-22T11:11:11+0000\",\n \"url\": \"https://abc/org/_git/repo/pullrequest/11151\",\n \"target\": \"develop\"\n },\n {\n \"key\": \"11346\",\n \"title\": \"feature/XXX-Validation\",\n \"branch\": \"feature/XXX-Validation\",\n \"base\": \"develop\",\n \"status\": {\n \"qualityGateStatus\": \"OK\",\n \"bugs\": 0,\n \"vulnerabilities\": 0,\n \"codeSmells\": 1\n },\n \"analysisDate\": \"2020-07-27T14:22:36+0000\",\n \"url\": \"https://abc/org/_git/repo/pullrequest/11346\",\n \"target\": \"develop\"\n }\n]\n","validation_input":"{\"pullRequests\": [{\"key\": \"999\", \"title\": \"t1\", \"branch\": \"b1\", \"base\": \"main\", \"status\": {\"qualityGateStatus\": \"WARN\", \"bugs\": 1, \"vulnerabilities\": 0, \"codeSmells\": 0}, \"analysisDate\": \"2021-01-01T00:00:00+0000\", \"url\": \"http://example.com/1\", \"target\": \"main\"}, {\"key\": \"100\", \"title\": \"t2\", \"branch\": \"b2\", \"base\": \"main\", \"status\": {\"qualityGateStatus\": \"ERROR\", \"bugs\": 5, \"vulnerabilities\": 2, \"codeSmells\": 10}, \"analysisDate\": \"2021-02-02T00:00:00+0000\", \"url\": \"http://example.com/2\", \"target\": \"main\"}]}","validation_output":"[\n {\n \"key\": \"100\",\n \"title\": \"t2\",\n \"branch\": \"b2\",\n \"base\": \"main\",\n \"status\": {\n \"qualityGateStatus\": \"ERROR\",\n \"bugs\": 5,\n \"vulnerabilities\": 2,\n \"codeSmells\": 10\n },\n \"analysisDate\": \"2021-02-02T00:00:00+0000\",\n \"url\": \"http://example.com/2\",\n \"target\": \"main\"\n },\n {\n \"key\": \"999\",\n \"title\": \"t1\",\n \"branch\": \"b1\",\n \"base\": \"main\",\n \"status\": {\n \"qualityGateStatus\": \"WARN\",\n \"bugs\": 1,\n \"vulnerabilities\": 0,\n \"codeSmells\": 0\n },\n \"analysisDate\": \"2021-01-01T00:00:00+0000\",\n \"url\": \"http://example.com/1\",\n \"target\": \"main\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63126834/sort-by-on-array-elements-gives-error-cannot-index-string-with-string-key","question_title":"sort_by on array elements gives error 'Cannot index string with string "key"'","question_owner":"AK123","answer_owner":"oguz ismail","answer_id":63127009,"question_score":7,"reviewed":true} {"id":"so-63126834-p1","request":"Order the pull request array based on their key field.","command":"jq '.pullRequests | sort_by(.key)'","input_text":"{\"pullRequests\": [{\"key\": \"11346\", \"title\": \"feature/XXX-Validation\", \"branch\": \"feature/XXX-Validation\", \"base\": \"develop\", \"status\": {\"qualityGateStatus\": \"OK\", \"bugs\": 0, \"vulnerabilities\": 0, \"codeSmells\": 1}, \"analysisDate\": \"2020-07-27T14:22:36+0000\", \"url\": \"https://abc/org/_git/repo/pullrequest/11346\", \"target\": \"develop\"}, {\"key\": \"11151\", \"title\": \"feature/xxx-data\", \"branch\": \"feature/xxx-data\", \"base\": \"develop\", \"status\": {\"qualityGateStatus\": \"OK\", \"bugs\": 0, \"vulnerabilities\": 0, \"codeSmells\": 0}, \"analysisDate\": \"2020-07-22T11:11:11+0000\", \"url\": \"https://abc/org/_git/repo/pullrequest/11151\", \"target\": \"develop\"}]}","expected_output":"[\n {\n \"key\": \"11151\",\n \"title\": \"feature/xxx-data\",\n \"branch\": \"feature/xxx-data\",\n \"base\": \"develop\",\n \"status\": {\n \"qualityGateStatus\": \"OK\",\n \"bugs\": 0,\n \"vulnerabilities\": 0,\n \"codeSmells\": 0\n },\n \"analysisDate\": \"2020-07-22T11:11:11+0000\",\n \"url\": \"https://abc/org/_git/repo/pullrequest/11151\",\n \"target\": \"develop\"\n },\n {\n \"key\": \"11346\",\n \"title\": \"feature/XXX-Validation\",\n \"branch\": \"feature/XXX-Validation\",\n \"base\": \"develop\",\n \"status\": {\n \"qualityGateStatus\": \"OK\",\n \"bugs\": 0,\n \"vulnerabilities\": 0,\n \"codeSmells\": 1\n },\n \"analysisDate\": \"2020-07-27T14:22:36+0000\",\n \"url\": \"https://abc/org/_git/repo/pullrequest/11346\",\n \"target\": \"develop\"\n }\n]\n","validation_input":"{\"pullRequests\": [{\"key\": \"999\", \"title\": \"t1\", \"branch\": \"b1\", \"base\": \"main\", \"status\": {\"qualityGateStatus\": \"WARN\", \"bugs\": 1, \"vulnerabilities\": 0, \"codeSmells\": 0}, \"analysisDate\": \"2021-01-01T00:00:00+0000\", \"url\": \"http://example.com/1\", \"target\": \"main\"}, {\"key\": \"100\", \"title\": \"t2\", \"branch\": \"b2\", \"base\": \"main\", \"status\": {\"qualityGateStatus\": \"ERROR\", \"bugs\": 5, \"vulnerabilities\": 2, \"codeSmells\": 10}, \"analysisDate\": \"2021-02-02T00:00:00+0000\", \"url\": \"http://example.com/2\", \"target\": \"main\"}]}","validation_output":"[\n {\n \"key\": \"100\",\n \"title\": \"t2\",\n \"branch\": \"b2\",\n \"base\": \"main\",\n \"status\": {\n \"qualityGateStatus\": \"ERROR\",\n \"bugs\": 5,\n \"vulnerabilities\": 2,\n \"codeSmells\": 10\n },\n \"analysisDate\": \"2021-02-02T00:00:00+0000\",\n \"url\": \"http://example.com/2\",\n \"target\": \"main\"\n },\n {\n \"key\": \"999\",\n \"title\": \"t1\",\n \"branch\": \"b1\",\n \"base\": \"main\",\n \"status\": {\n \"qualityGateStatus\": \"WARN\",\n \"bugs\": 1,\n \"vulnerabilities\": 0,\n \"codeSmells\": 0\n },\n \"analysisDate\": \"2021-01-01T00:00:00+0000\",\n \"url\": \"http://example.com/1\",\n \"target\": \"main\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63126834/sort-by-on-array-elements-gives-error-cannot-index-string-with-string-key","question_title":"sort_by on array elements gives error 'Cannot index string with string "key"'","question_owner":"AK123","answer_owner":"oguz ismail","answer_id":63127009,"question_score":7,"reviewed":true,"paraphrase_of":"so-63126834","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-63238759","request":"Extract the \"name\" values from objects where \"property\" is \"ENABLED\" and join them into a single space-separated string.","command":"jq -r '[.[] | select(.property == \"ENABLED\") | .name] | join(\" \")'","input_text":"{\"server1\":{\"name\":\"server1\",\"property\":\"ENABLED\"},\"server2\":{\"name\":\"server2\",\"property\":\"ENABLED\"},\"server3\":{\"name\":\"server3\",\"property\":\"ENABLED\"}}","expected_output":"server1 server2 server3\n","validation_input":"{\"s1\":{\"name\":\"alpha\",\"property\":\"ENABLED\"},\"s2\":{\"name\":\"beta\",\"property\":\"DISABLED\"},\"s3\":{\"name\":\"gamma\",\"property\":\"ENABLED\"}}","validation_output":"alpha gamma\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63238759/replace-n-with-space-in-jq-query-command-output-without-tr-and-sed-commands","question_title":"Replace \\n with space in jq query/command output without tr and sed commands","question_owner":"Zack","answer_owner":"dibery","answer_id":63239101,"question_score":5,"reviewed":true} {"id":"so-63238759-p1","request":"Gather \"name\" fields from objects having \"property\" set to \"ENABLED\" and combine them into one string separated by spaces.","command":"jq -r '[.[] | select(.property == \"ENABLED\") | .name] | join(\" \")'","input_text":"{\"server1\":{\"name\":\"server1\",\"property\":\"ENABLED\"},\"server2\":{\"name\":\"server2\",\"property\":\"ENABLED\"},\"server3\":{\"name\":\"server3\",\"property\":\"ENABLED\"}}","expected_output":"server1 server2 server3\n","validation_input":"{\"s1\":{\"name\":\"alpha\",\"property\":\"ENABLED\"},\"s2\":{\"name\":\"beta\",\"property\":\"DISABLED\"},\"s3\":{\"name\":\"gamma\",\"property\":\"ENABLED\"}}","validation_output":"alpha gamma\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63238759/replace-n-with-space-in-jq-query-command-output-without-tr-and-sed-commands","question_title":"Replace \\n with space in jq query/command output without tr and sed commands","question_owner":"Zack","answer_owner":"dibery","answer_id":63239101,"question_score":5,"reviewed":true,"paraphrase_of":"so-63238759","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-63472280","request":"Remove keys from the 'dic' object if they exist in the 'remove' object with a value of true.","command":"jq '[.remove | path(.[] | select(.))] as $p | .dic |= delpaths($p)'","input_text":"{\"dic\":{\"a\":\"\",\"b\":\"\",\"c\":\"\",\"d\":\"\"},\"remove\":{\"b\":true,\"c\":false,\"d\":true}}","expected_output":"{\n \"dic\": {\n \"a\": \"\",\n \"c\": \"\"\n },\n \"remove\": {\n \"b\": true,\n \"c\": false,\n \"d\": true\n }\n}\n","validation_input":"{\"dic\":{\"x\":1,\"y\":2,\"z\":3},\"remove\":{\"y\":true,\"z\":false}}","validation_output":"{\n \"dic\": {\n \"x\": 1,\n \"z\": 3\n },\n \"remove\": {\n \"y\": true,\n \"z\": false\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63472280/remove-keys-that-are-present-in-sibling-object-and-have-a-certain-value","question_title":"remove keys that are present in sibling object and have a certain value","question_owner":"Noim","answer_owner":"oguz ismail","answer_id":63472740,"question_score":5,"reviewed":true} {"id":"so-63472280-p1","request":"Delete keys from the 'dic' object that correspond to keys in the 'remove' object having a value of true.","command":"jq '[.remove | path(.[] | select(.))] as $p | .dic |= delpaths($p)'","input_text":"{\"dic\":{\"a\":\"\",\"b\":\"\",\"c\":\"\",\"d\":\"\"},\"remove\":{\"b\":true,\"c\":false,\"d\":true}}","expected_output":"{\n \"dic\": {\n \"a\": \"\",\n \"c\": \"\"\n },\n \"remove\": {\n \"b\": true,\n \"c\": false,\n \"d\": true\n }\n}\n","validation_input":"{\"dic\":{\"x\":1,\"y\":2,\"z\":3},\"remove\":{\"y\":true,\"z\":false}}","validation_output":"{\n \"dic\": {\n \"x\": 1,\n \"z\": 3\n },\n \"remove\": {\n \"y\": true,\n \"z\": false\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63472280/remove-keys-that-are-present-in-sibling-object-and-have-a-certain-value","question_title":"remove keys that are present in sibling object and have a certain value","question_owner":"Noim","answer_owner":"oguz ismail","answer_id":63472740,"question_score":5,"reviewed":true,"paraphrase_of":"so-63472280","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-63578959","request":"Read a stream of JSON objects from stdin. For each object, take the 'events' array and merge the parent object's fields (excluding 'events') into each event object. Output a single JSON array containing all the resulting flattened objects.","command":"jq -s '[ .[] | . as $parent | .events[] | . + ($parent | del(.events)) ]'","input_text":"{\"group\": \"A\", \"name\": \"abc\", \"events\": [{\"id\": \"54209\", \"message\": \"foobar 1\"}, {\"id\": \"76548\", \"message\": \"foobar 2\"}]}\n{\"group\": \"B\", \"name\": \"def\", \"events\": [{\"id\": \"54593\", \"message\": \"foobar 3\"}, {\"id\": \"20359\", \"message\": \"foobar 4\"}]}","expected_output":"[\n {\n \"id\": \"54209\",\n \"message\": \"foobar 1\",\n \"group\": \"A\",\n \"name\": \"abc\"\n },\n {\n \"id\": \"76548\",\n \"message\": \"foobar 2\",\n \"group\": \"A\",\n \"name\": \"abc\"\n },\n {\n \"id\": \"54593\",\n \"message\": \"foobar 3\",\n \"group\": \"B\",\n \"name\": \"def\"\n },\n {\n \"id\": \"20359\",\n \"message\": \"foobar 4\",\n \"group\": \"B\",\n \"name\": \"def\"\n }\n]\n","validation_input":"{\"group\": \"X\", \"name\": \"test\", \"events\": [{\"id\": \"1\", \"message\": \"m1\"}]}\n{\"group\": \"Y\", \"name\": \"test2\", \"events\": []}","validation_output":"[\n {\n \"id\": \"1\",\n \"message\": \"m1\",\n \"group\": \"X\",\n \"name\": \"test\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63578959/jq-flatten-parent-objects-into-children","question_title":"jq - flatten parent objects into children","question_owner":"Melvyn de Kort","answer_owner":"oguz ismail","answer_id":63579109,"question_score":6,"reviewed":true} {"id":"so-63635682","request":"Given a JSON object with a \"data\" array of objects, remove any key-value pairs where the value is an empty string from each object in the array. Additionally, for any remaining values that are strings ending with a colon and two digits (representing a port), remove that suffix.","command":"jq '.data |= map(with_entries(select(.value != \"\") | .value |= sub(\":[0-9][0-9]$\"; \"\")))'","input_text":"{\"data\":[{\"{#NAME}\":\"Test 1\",\"{#ID}\":\"1\",\"{#IP}\":\"192.168.1.2:80\"},{\"{#NAME}\":\"Test 2\",\"{#ID}\":\"2\",\"{#IP}\":\"\"},{\"{#NAME}\":\"Test 3\",\"{#ID}\":\"3\",\"{#IP}\":\"192.168.1.3:80\"}]}","expected_output":"{\n \"data\": [\n {\n \"{#NAME}\": \"Test 1\",\n \"{#ID}\": \"1\",\n \"{#IP}\": \"192.168.1.2\"\n },\n {\n \"{#NAME}\": \"Test 2\",\n \"{#ID}\": \"2\"\n },\n {\n \"{#NAME}\": \"Test 3\",\n \"{#ID}\": \"3\",\n \"{#IP}\": \"192.168.1.3\"\n }\n ]\n}\n","validation_input":"{\"data\":[{\"{#NAME}\":\"A\",\"{#ID}\":\"10\",\"{#IP}\":\"10.0.0.1:8080\"},{\"{#NAME}\":\"B\",\"{#ID}\":\"11\",\"{#IP}\":\"\"},{\"{#NAME}\":\"C\",\"{#ID}\":\"12\",\"{#IP}\":\"10.0.0.2\"}]}","validation_output":"{\n \"data\": [\n {\n \"{#NAME}\": \"A\",\n \"{#ID}\": \"10\",\n \"{#IP}\": \"10.0.0.1:8080\"\n },\n {\n \"{#NAME}\": \"B\",\n \"{#ID}\": \"11\"\n },\n {\n \"{#NAME}\": \"C\",\n \"{#ID}\": \"12\",\n \"{#IP}\": \"10.0.0.2\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63635682/jq-remove-keys-with-empty-string-values","question_title":"jq: Remove keys with empty string values","question_owner":"Joe","answer_owner":"Inian","answer_id":63635908,"question_score":5,"reviewed":true} {"id":"so-63635682-p1","request":"For each object in the \"data\" array of a JSON input, strip key-value pairs with empty string values and remove trailing colon-plus-two-digits suffixes from remaining string values.","command":"jq '.data |= map(with_entries(select(.value != \"\") | .value |= sub(\":[0-9][0-9]$\"; \"\")))'","input_text":"{\"data\":[{\"{#NAME}\":\"Test 1\",\"{#ID}\":\"1\",\"{#IP}\":\"192.168.1.2:80\"},{\"{#NAME}\":\"Test 2\",\"{#ID}\":\"2\",\"{#IP}\":\"\"},{\"{#NAME}\":\"Test 3\",\"{#ID}\":\"3\",\"{#IP}\":\"192.168.1.3:80\"}]}","expected_output":"{\n \"data\": [\n {\n \"{#NAME}\": \"Test 1\",\n \"{#ID}\": \"1\",\n \"{#IP}\": \"192.168.1.2\"\n },\n {\n \"{#NAME}\": \"Test 2\",\n \"{#ID}\": \"2\"\n },\n {\n \"{#NAME}\": \"Test 3\",\n \"{#ID}\": \"3\",\n \"{#IP}\": \"192.168.1.3\"\n }\n ]\n}\n","validation_input":"{\"data\":[{\"{#NAME}\":\"A\",\"{#ID}\":\"10\",\"{#IP}\":\"10.0.0.1:8080\"},{\"{#NAME}\":\"B\",\"{#ID}\":\"11\",\"{#IP}\":\"\"},{\"{#NAME}\":\"C\",\"{#ID}\":\"12\",\"{#IP}\":\"10.0.0.2\"}]}","validation_output":"{\n \"data\": [\n {\n \"{#NAME}\": \"A\",\n \"{#ID}\": \"10\",\n \"{#IP}\": \"10.0.0.1:8080\"\n },\n {\n \"{#NAME}\": \"B\",\n \"{#ID}\": \"11\"\n },\n {\n \"{#NAME}\": \"C\",\n \"{#ID}\": \"12\",\n \"{#IP}\": \"10.0.0.2\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63635682/jq-remove-keys-with-empty-string-values","question_title":"jq: Remove keys with empty string values","question_owner":"Joe","answer_owner":"Inian","answer_id":63635908,"question_score":5,"reviewed":true,"paraphrase_of":"so-63635682","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-63739892","request":"Sort the \"attributes\" array within each object of the \"link\" array by the \"name\" field.","command":"jq '.link[].attributes |= sort_by(.name)'","input_text":"{\"link\":[{\"attributes\":[{\"value\":\"ConfigurationElement\",\"name\":\"type\"},{\"value\":\"NAME1\",\"name\":\"name\"},{\"value\":\"0026a8b4-ced6-410e-9213-e3fcb28b3aab\",\"name\":\"id\"}],\"href\":\"href1\",\"rel\":\"down\"},{\"attributes\":[{\"value\":\"0026a8b4-ced6-410e-9213-k23g15h2u1l5\",\"name\":\"id\"},{\"value\":\"ConfigurationElement\",\"name\":\"type\"},{\"value\":\"NAME2\",\"name\":\"name\"}],\"href\":\"href2\",\"rel\":\"down\"}],\"total\":2}","expected_output":"{\n \"link\": [\n {\n \"attributes\": [\n {\n \"value\": \"0026a8b4-ced6-410e-9213-e3fcb28b3aab\",\n \"name\": \"id\"\n },\n {\n \"value\": \"NAME1\",\n \"name\": \"name\"\n },\n {\n \"value\": \"ConfigurationElement\",\n \"name\": \"type\"\n }\n ],\n \"href\": \"href1\",\n \"rel\": \"down\"\n },\n {\n \"attributes\": [\n {\n \"value\": \"0026a8b4-ced6-410e-9213-k23g15h2u1l5\",\n \"name\": \"id\"\n },\n {\n \"value\": \"NAME2\",\n \"name\": \"name\"\n },\n {\n \"value\": \"ConfigurationElement\",\n \"name\": \"type\"\n }\n ],\n \"href\": \"href2\",\n \"rel\": \"down\"\n }\n ],\n \"total\": 2\n}\n","validation_input":"{\"link\":[{\"attributes\":[{\"value\":\"Z\",\"name\":\"z_key\"},{\"value\":\"A\",\"name\":\"a_key\"}],\"href\":\"h1\",\"rel\":\"r1\"}],\"total\":1}","validation_output":"{\n \"link\": [\n {\n \"attributes\": [\n {\n \"value\": \"A\",\n \"name\": \"a_key\"\n },\n {\n \"value\": \"Z\",\n \"name\": \"z_key\"\n }\n ],\n \"href\": \"h1\",\n \"rel\": \"r1\"\n }\n ],\n \"total\": 1\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63739892/jq-sort-by-value-of-key","question_title":"jq sort by value of key","question_owner":"Future","answer_owner":"Weeble","answer_id":63740046,"question_score":5,"reviewed":true} {"id":"so-63739892-p1","request":"Sort the \"attributes\" array by \"name\" within every object contained in the \"link\" array.","command":"jq '.link[].attributes |= sort_by(.name)'","input_text":"{\"link\":[{\"attributes\":[{\"value\":\"ConfigurationElement\",\"name\":\"type\"},{\"value\":\"NAME1\",\"name\":\"name\"},{\"value\":\"0026a8b4-ced6-410e-9213-e3fcb28b3aab\",\"name\":\"id\"}],\"href\":\"href1\",\"rel\":\"down\"},{\"attributes\":[{\"value\":\"0026a8b4-ced6-410e-9213-k23g15h2u1l5\",\"name\":\"id\"},{\"value\":\"ConfigurationElement\",\"name\":\"type\"},{\"value\":\"NAME2\",\"name\":\"name\"}],\"href\":\"href2\",\"rel\":\"down\"}],\"total\":2}","expected_output":"{\n \"link\": [\n {\n \"attributes\": [\n {\n \"value\": \"0026a8b4-ced6-410e-9213-e3fcb28b3aab\",\n \"name\": \"id\"\n },\n {\n \"value\": \"NAME1\",\n \"name\": \"name\"\n },\n {\n \"value\": \"ConfigurationElement\",\n \"name\": \"type\"\n }\n ],\n \"href\": \"href1\",\n \"rel\": \"down\"\n },\n {\n \"attributes\": [\n {\n \"value\": \"0026a8b4-ced6-410e-9213-k23g15h2u1l5\",\n \"name\": \"id\"\n },\n {\n \"value\": \"NAME2\",\n \"name\": \"name\"\n },\n {\n \"value\": \"ConfigurationElement\",\n \"name\": \"type\"\n }\n ],\n \"href\": \"href2\",\n \"rel\": \"down\"\n }\n ],\n \"total\": 2\n}\n","validation_input":"{\"link\":[{\"attributes\":[{\"value\":\"Z\",\"name\":\"z_key\"},{\"value\":\"A\",\"name\":\"a_key\"}],\"href\":\"h1\",\"rel\":\"r1\"}],\"total\":1}","validation_output":"{\n \"link\": [\n {\n \"attributes\": [\n {\n \"value\": \"A\",\n \"name\": \"a_key\"\n },\n {\n \"value\": \"Z\",\n \"name\": \"z_key\"\n }\n ],\n \"href\": \"h1\",\n \"rel\": \"r1\"\n }\n ],\n \"total\": 1\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/63739892/jq-sort-by-value-of-key","question_title":"jq sort by value of key","question_owner":"Future","answer_owner":"Weeble","answer_id":63740046,"question_score":5,"reviewed":true,"paraphrase_of":"so-63739892","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-64140869","request":"Convert a flat JSON object into a list of lines where each line is formatted as 'key=value'.","command":"jq -r 'to_entries[] | \"\\(.key)=\\(.value)\"'","input_text":"{\n \"author\": \"tomek\",\n \"title\": \"helloworld\",\n \"test\": \"sampletextonetwothree\"\n}","expected_output":"author=tomek\ntitle=helloworld\ntest=sampletextonetwothree\n","validation_input":"{\n \"name\": \"alice\",\n \"age\": 30,\n \"city\": \"new york\"\n}","validation_output":"name=alice\nage=30\ncity=new york\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64140869/json-to-plain-text-using-jq","question_title":"JSON to plain text using jq","question_owner":"user6524131","answer_owner":"EdvardM","answer_id":64141445,"question_score":5,"reviewed":true} {"id":"so-64140869-p1","request":"Transform a flat JSON object into lines formatted as 'key=value'.","command":"jq -r 'to_entries[] | \"\\(.key)=\\(.value)\"'","input_text":"{\n \"author\": \"tomek\",\n \"title\": \"helloworld\",\n \"test\": \"sampletextonetwothree\"\n}","expected_output":"author=tomek\ntitle=helloworld\ntest=sampletextonetwothree\n","validation_input":"{\n \"name\": \"alice\",\n \"age\": 30,\n \"city\": \"new york\"\n}","validation_output":"name=alice\nage=30\ncity=new york\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64140869/json-to-plain-text-using-jq","question_title":"JSON to plain text using jq","question_owner":"user6524131","answer_owner":"EdvardM","answer_id":64141445,"question_score":5,"reviewed":true,"paraphrase_of":"so-64140869","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-64605920","request":"Merge the nested object under key 'a' with the rest of the top-level object, effectively spreading 'a's properties into the root while keeping other keys like 'b'.","command":"jq '.a + del(.a)'","input_text":"{\"a\": {\"a1\": 1, \"a2\": 2}, \"b\": 3}\n{\"a\": {\"x\": 10}, \"b\": 20, \"c\": 30}","expected_output":"{\n \"a1\": 1,\n \"a2\": 2,\n \"b\": 3\n}\n{\n \"x\": 10,\n \"b\": 20,\n \"c\": 30\n}\n","validation_input":"{\"a\": {\"a1\": 1, \"a2\": 2}, \"b\": 3}","validation_output":"{\n \"a1\": 1,\n \"a2\": 2,\n \"b\": 3\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64605920/how-can-i-spread-an-objects-properties-in-jq","question_title":"How can I spread an object's properties in jq?","question_owner":"nachocab","answer_owner":"Weeble","answer_id":64605999,"question_score":7,"reviewed":true} {"id":"so-64605920-p1","request":"Spread the properties of the nested object at key 'a' into the root level, merging them with other top-level keys like 'b'.","command":"jq '.a + del(.a)'","input_text":"{\"a\": {\"a1\": 1, \"a2\": 2}, \"b\": 3}\n{\"a\": {\"x\": 10}, \"b\": 20, \"c\": 30}","expected_output":"{\n \"a1\": 1,\n \"a2\": 2,\n \"b\": 3\n}\n{\n \"x\": 10,\n \"b\": 20,\n \"c\": 30\n}\n","validation_input":"{\"a\": {\"a1\": 1, \"a2\": 2}, \"b\": 3}","validation_output":"{\n \"a1\": 1,\n \"a2\": 2,\n \"b\": 3\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64605920/how-can-i-spread-an-objects-properties-in-jq","question_title":"How can I spread an object's properties in jq?","question_owner":"nachocab","answer_owner":"Weeble","answer_id":64605999,"question_score":7,"reviewed":true,"paraphrase_of":"so-64605920","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-64698091","request":"Select all objects tied for the minimum value of the 'number' field from a JSON array of objects.","command":"jq '([ .[].number ] | min) as $m | map(select(.number == $m))'","input_text":"[{\"number\":1},{\"number\":3}]","expected_output":"[\n {\n \"number\": 1\n }\n]\n","validation_input":"[{\"number\":5},{\"number\":2},{\"number\":8}]","validation_output":"[\n {\n \"number\": 2\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64698091/jq-select-record-from-array-with-min-or-max-value-of-field","question_title":"jq select record from array with min or max value of field","question_owner":"Artem Trunov","answer_owner":"peak","answer_id":64701732,"question_score":5,"reviewed":true} {"id":"so-64698091-p1","request":"From a JSON array of objects, select all entries that share the minimum value found in the 'number' field.","command":"jq '([ .[].number ] | min) as $m | map(select(.number == $m))'","input_text":"[{\"number\":1},{\"number\":3}]","expected_output":"[\n {\n \"number\": 1\n }\n]\n","validation_input":"[{\"number\":5},{\"number\":2},{\"number\":8}]","validation_output":"[\n {\n \"number\": 2\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64698091/jq-select-record-from-array-with-min-or-max-value-of-field","question_title":"jq select record from array with min or max value of field","question_owner":"Artem Trunov","answer_owner":"peak","answer_id":64701732,"question_score":5,"reviewed":true,"paraphrase_of":"so-64698091","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-64957982","request":"Convert a number to a string padded with leading zeros to ensure a total length of at least 3 characters.","command":"jq 'tostring | (length | if . >= 3 then \"\" else \"0\" * (3 - .) end) as $padding | \"\\($padding)\\(.)\"'","input_text":"7","expected_output":"\"007\"\n","validation_input":"42","validation_output":"\"042\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64957982/how-can-i-pad-numbers-with-jq","question_title":"How can I pad numbers with 'jq'?","question_owner":"Martin Mucha","answer_owner":"customcommander","answer_id":64958079,"question_score":6,"reviewed":true} {"id":"so-64957982-p1","request":"Format a number as a string with leading zeros to ensure a minimum length of 3 characters.","command":"jq 'tostring | (length | if . >= 3 then \"\" else \"0\" * (3 - .) end) as $padding | \"\\($padding)\\(.)\"'","input_text":"7","expected_output":"\"007\"\n","validation_input":"42","validation_output":"\"042\"\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/64957982/how-can-i-pad-numbers-with-jq","question_title":"How can I pad numbers with 'jq'?","question_owner":"Martin Mucha","answer_owner":"customcommander","answer_id":64958079,"question_score":6,"reviewed":true,"paraphrase_of":"so-64957982","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-65449514","request":"Extract the value of the first key in the input JSON object, regardless of the key's name.","command":"jq -r 'first(.[])'","input_text":"{\"RandomKey1\":\"3.1.44.0\",\"Common\":{\"Services\":\"3.50.103.0\"}}","expected_output":"3.1.44.0\n","validation_input":"{\"AnotherKey\":\"1.2.3.4\",\"Data\":{\"Version\":\"2.0.0\"}}","validation_output":"1.2.3.4\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/65449514/print-the-first-value-without-knowing-the-key","question_title":"Print the first value without knowing the key","question_owner":"zeroweb","answer_owner":"oguz ismail","answer_id":65449577,"question_score":6,"reviewed":true} {"id":"so-65449514-p1","request":"Retrieve the value associated with the first key in the input JSON object, ignoring the key name.","command":"jq -r 'first(.[])'","input_text":"{\"RandomKey1\":\"3.1.44.0\",\"Common\":{\"Services\":\"3.50.103.0\"}}","expected_output":"3.1.44.0\n","validation_input":"{\"AnotherKey\":\"1.2.3.4\",\"Data\":{\"Version\":\"2.0.0\"}}","validation_output":"1.2.3.4\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/65449514/print-the-first-value-without-knowing-the-key","question_title":"Print the first value without knowing the key","question_owner":"zeroweb","answer_owner":"oguz ismail","answer_id":65449577,"question_score":6,"reviewed":true,"paraphrase_of":"so-65449514","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-65717880","request":"Filter the ipAddressTab array to include only objects where status is 'reserved' and type is not 'network', 'gateway', or 'broadcast', returning the result as a JSON array.","command":"jq '[.ipAddressTab[] | select(.status == \"reserved\") | select(.type != \"network\" and .type != \"gateway\" and .type != \"broadcast\")]'","input_text":"{\"cidr\":\"10.0.0.0/27\",\"defaultGateway\":\"10.0.0.1\",\"full\":false,\"id\":\"net1\",\"ipAddressTab\":[{\"alias_domain\":null,\"alias_name\":null,\"description\":\"network addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.0\",\"requester\":null,\"status\":\"reserved\",\"type\":\"network\"},{\"alias_domain\":null,\"alias_name\":null,\"description\":\"gateway addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.1\",\"requester\":null,\"status\":\"reserved\",\"type\":\"gateway\"},{\"alias_domain\":\"toto.com\",\"alias_name\":\"\",\"description\":\"test vm\",\"dns_domain\":\"\",\"environnement\":\"test\",\"fdqn\":\"XXX\",\"hostname\":\"XXX\",\"ip\":\"10.0.0.2\",\"requester\":\"XXX\",\"status\":\"allocated\",\"type\":\"VM\"},{\"ip\":\"10.0.0.3\",\"status\":\"reserved\"},{\"ip\":\"10.0.0.4\",\"status\":\"reserved\"},{\"alias_domain\":null,\"alias_name\":null,\"description\":\"broadcast addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.31\",\"requester\":null,\"status\":\"reserved\",\"type\":\"broadcast\"}]}","expected_output":"[\n {\n \"ip\": \"10.0.0.3\",\n \"status\": \"reserved\"\n },\n {\n \"ip\": \"10.0.0.4\",\n \"status\": \"reserved\"\n }\n]\n","validation_input":"{\"cidr\":\"192.168.1.0/24\",\"defaultGateway\":\"192.168.1.1\",\"full\":true,\"id\":\"net2\",\"ipAddressTab\":[{\"ip\":\"192.168.1.0\",\"status\":\"reserved\",\"type\":\"network\"},{\"ip\":\"192.168.1.1\",\"status\":\"reserved\",\"type\":\"gateway\"},{\"ip\":\"192.168.1.2\",\"status\":\"reserved\"},{\"ip\":\"192.168.1.3\",\"status\":\"allocated\",\"type\":\"VM\"},{\"ip\":\"192.168.1.255\",\"status\":\"reserved\",\"type\":\"broadcast\"}]}","validation_output":"[\n {\n \"ip\": \"192.168.1.2\",\n \"status\": \"reserved\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/65717880/parsing-json-with-jq-where-are-the-comma","question_title":"Parsing json with JQ : Where are the comma?","question_owner":"Drak432","answer_owner":"Weeble","answer_id":65718417,"question_score":5,"reviewed":true} {"id":"so-65717880-p1","request":"Filter the ipAddressTab array for objects where status is 'reserved' and type is neither 'network', 'gateway', nor 'broadcast', returning the matches as a JSON array.","command":"jq '[.ipAddressTab[] | select(.status == \"reserved\") | select(.type != \"network\" and .type != \"gateway\" and .type != \"broadcast\")]'","input_text":"{\"cidr\":\"10.0.0.0/27\",\"defaultGateway\":\"10.0.0.1\",\"full\":false,\"id\":\"net1\",\"ipAddressTab\":[{\"alias_domain\":null,\"alias_name\":null,\"description\":\"network addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.0\",\"requester\":null,\"status\":\"reserved\",\"type\":\"network\"},{\"alias_domain\":null,\"alias_name\":null,\"description\":\"gateway addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.1\",\"requester\":null,\"status\":\"reserved\",\"type\":\"gateway\"},{\"alias_domain\":\"toto.com\",\"alias_name\":\"\",\"description\":\"test vm\",\"dns_domain\":\"\",\"environnement\":\"test\",\"fdqn\":\"XXX\",\"hostname\":\"XXX\",\"ip\":\"10.0.0.2\",\"requester\":\"XXX\",\"status\":\"allocated\",\"type\":\"VM\"},{\"ip\":\"10.0.0.3\",\"status\":\"reserved\"},{\"ip\":\"10.0.0.4\",\"status\":\"reserved\"},{\"alias_domain\":null,\"alias_name\":null,\"description\":\"broadcast addr\",\"dnr_rr\":null,\"dns_domain\":null,\"environnement\":null,\"fdqn\":null,\"hostname\":null,\"ip\":\"10.0.0.31\",\"requester\":null,\"status\":\"reserved\",\"type\":\"broadcast\"}]}","expected_output":"[\n {\n \"ip\": \"10.0.0.3\",\n \"status\": \"reserved\"\n },\n {\n \"ip\": \"10.0.0.4\",\n \"status\": \"reserved\"\n }\n]\n","validation_input":"{\"cidr\":\"192.168.1.0/24\",\"defaultGateway\":\"192.168.1.1\",\"full\":true,\"id\":\"net2\",\"ipAddressTab\":[{\"ip\":\"192.168.1.0\",\"status\":\"reserved\",\"type\":\"network\"},{\"ip\":\"192.168.1.1\",\"status\":\"reserved\",\"type\":\"gateway\"},{\"ip\":\"192.168.1.2\",\"status\":\"reserved\"},{\"ip\":\"192.168.1.3\",\"status\":\"allocated\",\"type\":\"VM\"},{\"ip\":\"192.168.1.255\",\"status\":\"reserved\",\"type\":\"broadcast\"}]}","validation_output":"[\n {\n \"ip\": \"192.168.1.2\",\n \"status\": \"reserved\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/65717880/parsing-json-with-jq-where-are-the-comma","question_title":"Parsing json with JQ : Where are the comma?","question_owner":"Drak432","answer_owner":"Weeble","answer_id":65718417,"question_score":5,"reviewed":true,"paraphrase_of":"so-65717880","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-67250481","request":"Output each string in the 'serviceArns' array that contains the substring 'edp-api-dev' as a raw string, one per line.","command":"jq -r '.serviceArns[] | select(contains(\"edp-api-dev\"))'","input_text":"{\"serviceArns\":[\"arn:aws:ecs:us-east-1:1234:service/splat-dev/abc-api-dev-ecs-abc-api-man-1920299\",\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-ecs-edp-api-man-721g8a7d\",\"arn:aws:ecs:us-east-1:1234:service/tsm-frontend-dev-ecs-tsm-frontend-man\"]}","expected_output":"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-ecs-edp-api-man-721g8a7d\n","validation_input":"{\"serviceArns\":[\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-1\",\"arn:aws:ecs:us-east-1:1234:service/other-service\",\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-2\"]}","validation_output":"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-1\narn:aws:ecs:us-east-1:1234:service/edp-api-dev-2\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/67250481/how-to-filter-using-jq-array-of-strings-which-contains-a-specific-value","question_title":"How to filter using jq array of strings which contains a specific value","question_owner":"kumar","answer_owner":"kumar","answer_id":67250722,"question_score":5,"reviewed":true} {"id":"so-67250481-p1","request":"Print each string from the 'serviceArns' array containing 'edp-api-dev' on its own line as a raw string.","command":"jq -r '.serviceArns[] | select(contains(\"edp-api-dev\"))'","input_text":"{\"serviceArns\":[\"arn:aws:ecs:us-east-1:1234:service/splat-dev/abc-api-dev-ecs-abc-api-man-1920299\",\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-ecs-edp-api-man-721g8a7d\",\"arn:aws:ecs:us-east-1:1234:service/tsm-frontend-dev-ecs-tsm-frontend-man\"]}","expected_output":"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-ecs-edp-api-man-721g8a7d\n","validation_input":"{\"serviceArns\":[\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-1\",\"arn:aws:ecs:us-east-1:1234:service/other-service\",\"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-2\"]}","validation_output":"arn:aws:ecs:us-east-1:1234:service/edp-api-dev-1\narn:aws:ecs:us-east-1:1234:service/edp-api-dev-2\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/67250481/how-to-filter-using-jq-array-of-strings-which-contains-a-specific-value","question_title":"How to filter using jq array of strings which contains a specific value","question_owner":"kumar","answer_owner":"kumar","answer_id":67250722,"question_score":5,"reviewed":true,"paraphrase_of":"so-67250481","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-67897266","request":"Convert each key-value pair in the input JSON object into a shell-safe assignment string formatted as KEY=VALUE, where VALUE is quoted using single quotes and escaped appropriately for shell usage.","command":"jq -r 'to_entries[] | \"\\(.key)=\\(.value|@sh)\"'","input_text":"{\"PD_TOKEN\":\"Token y_NbAkKc66ryYTWUXYEu\",\"API\":\"http://cool.api/\",\"HELP_URL\":\"https://help.com\"}","expected_output":"PD_TOKEN='Token y_NbAkKc66ryYTWUXYEu'\nAPI='http://cool.api/'\nHELP_URL='https://help.com'\n","validation_input":"{\"USER\":\"John Doe\",\"PATH\":\"/usr/bin:/bin\",\"MSG\":\"It's a \\\"test\\\"\"}","validation_output":"USER='John Doe'\nPATH='/usr/bin:/bin'\nMSG='It'\\''s a \"test\"'\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/67897266/how-to-insert-quotes-in-jq-string-interpolation-in-bash","question_title":"How to insert quotes in jq string interpolation in bash","question_owner":"motionsickness","answer_owner":"Benjamin W.","answer_id":67897417,"question_score":5,"reviewed":true} {"id":"so-67897266-p1","request":"Convert each key-value pair in the input JSON object into a shell-safe assignment string formatted as KEY='VALUE', with proper single-quote escaping.","command":"jq -r 'to_entries[] | \"\\(.key)=\\(.value|@sh)\"'","input_text":"{\"PD_TOKEN\":\"Token y_NbAkKc66ryYTWUXYEu\",\"API\":\"http://cool.api/\",\"HELP_URL\":\"https://help.com\"}","expected_output":"PD_TOKEN='Token y_NbAkKc66ryYTWUXYEu'\nAPI='http://cool.api/'\nHELP_URL='https://help.com'\n","validation_input":"{\"USER\":\"John Doe\",\"PATH\":\"/usr/bin:/bin\",\"MSG\":\"It's a \\\"test\\\"\"}","validation_output":"USER='John Doe'\nPATH='/usr/bin:/bin'\nMSG='It'\\''s a \"test\"'\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/67897266/how-to-insert-quotes-in-jq-string-interpolation-in-bash","question_title":"How to insert quotes in jq string interpolation in bash","question_owner":"motionsickness","answer_owner":"Benjamin W.","answer_id":67897417,"question_score":5,"reviewed":true,"paraphrase_of":"so-67897266","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-68074046","request":"Output the entire JSON document, but set the top-level \"ETag\" field to an empty string and update the \"OriginPath\" of the item in \".DistributionConfig.Origins.Items\" whose \"Id\" is \"redacted-2\" to \"foo\".","command":"jq '.ETag = \"\" | (.DistributionConfig.Origins.Items[] | select(.Id == \"redacted-2\")).OriginPath = \"foo\"'","input_text":"{\"ETag\": \"REDACTED\", \"DistributionConfig\": {\"Origins\": {\"Quantity\": 2, \"Items\": [{\"Id\": \"redacted-1\", \"DomainName\": \"redacted1.us-east-1.amazonaws.com\", \"OriginPath\": \"/redacted\"}, {\"Id\": \"redacted-2\", \"DomainName\": \"redacted2.s3.amazonaws.com\", \"OriginPath\": \"\"}]}}}","expected_output":"{\n \"ETag\": \"\",\n \"DistributionConfig\": {\n \"Origins\": {\n \"Quantity\": 2,\n \"Items\": [\n {\n \"Id\": \"redacted-1\",\n \"DomainName\": \"redacted1.us-east-1.amazonaws.com\",\n \"OriginPath\": \"/redacted\"\n },\n {\n \"Id\": \"redacted-2\",\n \"DomainName\": \"redacted2.s3.amazonaws.com\",\n \"OriginPath\": \"foo\"\n }\n ]\n }\n }\n}\n","validation_input":"{\"ETag\": \"ABC123\", \"DistributionConfig\": {\"Origins\": {\"Quantity\": 1, \"Items\": [{\"Id\": \"redacted-2\", \"DomainName\": \"example.com\", \"OriginPath\": \"/old\"}]}}}","validation_output":"{\n \"ETag\": \"\",\n \"DistributionConfig\": {\n \"Origins\": {\n \"Quantity\": 1,\n \"Items\": [\n {\n \"Id\": \"redacted-2\",\n \"DomainName\": \"example.com\",\n \"OriginPath\": \"foo\"\n }\n ]\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68074046/how-can-i-output-the-whole-document-in-jq-while-replacing-an-item-based-on-a-fie","question_title":"How can I output the whole document in jq while replacing an item based on a field's value?","question_owner":"SeanKilleen","answer_owner":"chepner","answer_id":68074534,"question_score":5,"reviewed":true} {"id":"so-68074046-p1","request":"Output the full JSON document with the top-level \"ETag\" set to an empty string and the \"OriginPath\" updated to \"foo\" for the item in \".DistributionConfig.Origins.Items\" having an \"Id\" of \"redacted-2\".","command":"jq '.ETag = \"\" | (.DistributionConfig.Origins.Items[] | select(.Id == \"redacted-2\")).OriginPath = \"foo\"'","input_text":"{\"ETag\": \"REDACTED\", \"DistributionConfig\": {\"Origins\": {\"Quantity\": 2, \"Items\": [{\"Id\": \"redacted-1\", \"DomainName\": \"redacted1.us-east-1.amazonaws.com\", \"OriginPath\": \"/redacted\"}, {\"Id\": \"redacted-2\", \"DomainName\": \"redacted2.s3.amazonaws.com\", \"OriginPath\": \"\"}]}}}","expected_output":"{\n \"ETag\": \"\",\n \"DistributionConfig\": {\n \"Origins\": {\n \"Quantity\": 2,\n \"Items\": [\n {\n \"Id\": \"redacted-1\",\n \"DomainName\": \"redacted1.us-east-1.amazonaws.com\",\n \"OriginPath\": \"/redacted\"\n },\n {\n \"Id\": \"redacted-2\",\n \"DomainName\": \"redacted2.s3.amazonaws.com\",\n \"OriginPath\": \"foo\"\n }\n ]\n }\n }\n}\n","validation_input":"{\"ETag\": \"ABC123\", \"DistributionConfig\": {\"Origins\": {\"Quantity\": 1, \"Items\": [{\"Id\": \"redacted-2\", \"DomainName\": \"example.com\", \"OriginPath\": \"/old\"}]}}}","validation_output":"{\n \"ETag\": \"\",\n \"DistributionConfig\": {\n \"Origins\": {\n \"Quantity\": 1,\n \"Items\": [\n {\n \"Id\": \"redacted-2\",\n \"DomainName\": \"example.com\",\n \"OriginPath\": \"foo\"\n }\n ]\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68074046/how-can-i-output-the-whole-document-in-jq-while-replacing-an-item-based-on-a-fie","question_title":"How can I output the whole document in jq while replacing an item based on a field's value?","question_owner":"SeanKilleen","answer_owner":"chepner","answer_id":68074534,"question_score":5,"reviewed":true,"paraphrase_of":"so-68074046","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-68159673","request":"Check if the 'user' field contains the substring 'thinking' in a case-insensitive manner.","command":"jq '.user | ascii_downcase | contains(\"thinking\")'","input_text":"{\"id\": \"1338268256814161923\", \"user\": \"Thinking of going through the Venmo transactions on my feed and liking all of them just to create a little sense of vulnerability\"}\n","expected_output":"true\n","validation_input":"{\"id\": \"2\", \"user\": \"I am not THINKING about it\"}\n","validation_output":"true\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68159673/jq-case-insensitive-contains","question_title":"jq case insensitive contains","question_owner":"Fight Daily","answer_owner":"peak","answer_id":68160770,"question_score":5,"reviewed":true} {"id":"so-68159673-p1","request":"Determine if the 'user' field includes the substring 'thinking', ignoring case.","command":"jq '.user | ascii_downcase | contains(\"thinking\")'","input_text":"{\"id\": \"1338268256814161923\", \"user\": \"Thinking of going through the Venmo transactions on my feed and liking all of them just to create a little sense of vulnerability\"}\n","expected_output":"true\n","validation_input":"{\"id\": \"2\", \"user\": \"I am not THINKING about it\"}\n","validation_output":"true\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68159673/jq-case-insensitive-contains","question_title":"jq case insensitive contains","question_owner":"Fight Daily","answer_owner":"peak","answer_id":68160770,"question_score":5,"reviewed":true,"paraphrase_of":"so-68159673","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-68818940","request":"Filter the input JSON array to include only objects where the 'size' field is greater than 1000. For each remaining object, output a line in the format 'name,size' using comma separation.","command":"jq -r '.[] | select(.size > 1000) | [.name, .size] | join(\",\")'","input_text":"[{\"name\":\"name1\",\"size\":1024},{\"name\":\"name2\",\"size\":300},{\"name\":\"name3\",\"size\":512}]","expected_output":"name1,1024\n","validation_input":"[{\"name\":\"alpha\",\"size\":2000},{\"name\":\"beta\",\"size\":500},{\"name\":\"gamma\",\"size\":1500}]","validation_output":"alpha,2000\ngamma,1500\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68818940/produce-output-for-values-greater-than-n-and-ignore-the-rest-in-jq","question_title":"Produce output for values greater than n and ignore the rest in JQ","question_owner":"DisplayName","answer_owner":"oguz ismail","answer_id":68819110,"question_score":6,"reviewed":true} {"id":"so-68818940-p1","request":"Filter the input JSON array for objects with a 'size' exceeding 1000, then print each match as 'name,size'.","command":"jq -r '.[] | select(.size > 1000) | [.name, .size] | join(\",\")'","input_text":"[{\"name\":\"name1\",\"size\":1024},{\"name\":\"name2\",\"size\":300},{\"name\":\"name3\",\"size\":512}]","expected_output":"name1,1024\n","validation_input":"[{\"name\":\"alpha\",\"size\":2000},{\"name\":\"beta\",\"size\":500},{\"name\":\"gamma\",\"size\":1500}]","validation_output":"alpha,2000\ngamma,1500\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/68818940/produce-output-for-values-greater-than-n-and-ignore-the-rest-in-jq","question_title":"Produce output for values greater than n and ignore the rest in JQ","question_owner":"DisplayName","answer_owner":"oguz ismail","answer_id":68819110,"question_score":6,"reviewed":true,"paraphrase_of":"so-68818940","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-69172925","request":"From an array of objects, extract the value of the \"name\" field from each object and return a sorted array of unique names.","command":"jq 'map(.name) | unique'","input_text":"[\n {\"name\": \"Joe\", \"age\": 21},\n {\"name\": \"Steve\", \"age\": 27},\n {\"name\": \"Michelle\", \"age\": 32},\n {\"name\": \"Joe\", \"age\": 23}\n]","expected_output":"[\n \"Joe\",\n \"Michelle\",\n \"Steve\"\n]\n","validation_input":"[\n {\"name\": \"Alice\", \"id\": 1},\n {\"name\": \"Bob\", \"id\": 2},\n {\"name\": \"Alice\", \"id\": 3}\n]","validation_output":"[\n \"Alice\",\n \"Bob\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/69172925/jq-get-all-unique-values-for-a-given-key-in-a-list-of-objects","question_title":"jq get all unique values for a given key in a list of objects","question_owner":"Johnny Metz","answer_owner":"peak","answer_id":69173048,"question_score":9,"reviewed":true} {"id":"so-69172925-p1","request":"Retrieve unique 'name' values from an array of objects and return them in sorted order.","command":"jq 'map(.name) | unique'","input_text":"[\n {\"name\": \"Joe\", \"age\": 21},\n {\"name\": \"Steve\", \"age\": 27},\n {\"name\": \"Michelle\", \"age\": 32},\n {\"name\": \"Joe\", \"age\": 23}\n]","expected_output":"[\n \"Joe\",\n \"Michelle\",\n \"Steve\"\n]\n","validation_input":"[\n {\"name\": \"Alice\", \"id\": 1},\n {\"name\": \"Bob\", \"id\": 2},\n {\"name\": \"Alice\", \"id\": 3}\n]","validation_output":"[\n \"Alice\",\n \"Bob\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/69172925/jq-get-all-unique-values-for-a-given-key-in-a-list-of-objects","question_title":"jq get all unique values for a given key in a list of objects","question_owner":"Johnny Metz","answer_owner":"peak","answer_id":69173048,"question_score":9,"reviewed":true,"paraphrase_of":"so-69172925","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-70015029","request":"Read a stream of JSON objects from stdin, each containing a 'data' array. Extract all items from these arrays, remove duplicates based on the 'hash' field, and output the remaining unique objects as a JSON array.","command":"jq -s '[.[] | .data[]] | unique_by(.hash)'","input_text":"{\"data\": [{\"account\": \"12x\", \"amount\": 7885016, \"block\": 470788, \"gateway\": \"113k\", \"hash\": \"DTU1\", \"timestamp\": \"2020-08-28T01:29:46.000000Z\"}]}\n{\"data\": [{\"account\": \"12x\", \"amount\": 7885016, \"block\": 470788, \"gateway\": \"113k\", \"hash\": \"DTU1\", \"timestamp\": \"2020-08-28T01:29:46.000000Z\"}]}\n{\"data\": [{\"account\": \"12y\", \"amount\": 8623955, \"block\": 470509, \"gateway\": \"113k\", \"hash\": \"5fQJ\", \"timestamp\": \"2020-08-27T19:01:48.000000Z\"}]}","expected_output":"[\n {\n \"account\": \"12y\",\n \"amount\": 8623955,\n \"block\": 470509,\n \"gateway\": \"113k\",\n \"hash\": \"5fQJ\",\n \"timestamp\": \"2020-08-27T19:01:48.000000Z\"\n },\n {\n \"account\": \"12x\",\n \"amount\": 7885016,\n \"block\": 470788,\n \"gateway\": \"113k\",\n \"hash\": \"DTU1\",\n \"timestamp\": \"2020-08-28T01:29:46.000000Z\"\n }\n]\n","validation_input":"{\"data\": [{\"account\": \"A\", \"amount\": 100, \"block\": 1, \"gateway\": \"G1\", \"hash\": \"H1\", \"timestamp\": \"T1\"}]}\n{\"data\": [{\"account\": \"B\", \"amount\": 200, \"block\": 2, \"gateway\": \"G2\", \"hash\": \"H2\", \"timestamp\": \"T2\"}]}\n{\"data\": [{\"account\": \"A\", \"amount\": 100, \"block\": 1, \"gateway\": \"G1\", \"hash\": \"H1\", \"timestamp\": \"T1\"}]}","validation_output":"[\n {\n \"account\": \"A\",\n \"amount\": 100,\n \"block\": 1,\n \"gateway\": \"G1\",\n \"hash\": \"H1\",\n \"timestamp\": \"T1\"\n },\n {\n \"account\": \"B\",\n \"amount\": 200,\n \"block\": 2,\n \"gateway\": \"G2\",\n \"hash\": \"H2\",\n \"timestamp\": \"T2\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70015029/get-unique-objects-and-arrays-based-on-key-value","question_title":"Get unique objects and arrays based on key value","question_owner":"Nick Hatfield","answer_owner":"peak","answer_id":70016167,"question_score":5,"reviewed":true} {"id":"so-70015029-p1","request":"Read JSON objects from stdin containing a 'data' array, flatten all items, deduplicate by 'hash', and output the result as a JSON array.","command":"jq -s '[.[] | .data[]] | unique_by(.hash)'","input_text":"{\"data\": [{\"account\": \"12x\", \"amount\": 7885016, \"block\": 470788, \"gateway\": \"113k\", \"hash\": \"DTU1\", \"timestamp\": \"2020-08-28T01:29:46.000000Z\"}]}\n{\"data\": [{\"account\": \"12x\", \"amount\": 7885016, \"block\": 470788, \"gateway\": \"113k\", \"hash\": \"DTU1\", \"timestamp\": \"2020-08-28T01:29:46.000000Z\"}]}\n{\"data\": [{\"account\": \"12y\", \"amount\": 8623955, \"block\": 470509, \"gateway\": \"113k\", \"hash\": \"5fQJ\", \"timestamp\": \"2020-08-27T19:01:48.000000Z\"}]}","expected_output":"[\n {\n \"account\": \"12y\",\n \"amount\": 8623955,\n \"block\": 470509,\n \"gateway\": \"113k\",\n \"hash\": \"5fQJ\",\n \"timestamp\": \"2020-08-27T19:01:48.000000Z\"\n },\n {\n \"account\": \"12x\",\n \"amount\": 7885016,\n \"block\": 470788,\n \"gateway\": \"113k\",\n \"hash\": \"DTU1\",\n \"timestamp\": \"2020-08-28T01:29:46.000000Z\"\n }\n]\n","validation_input":"{\"data\": [{\"account\": \"A\", \"amount\": 100, \"block\": 1, \"gateway\": \"G1\", \"hash\": \"H1\", \"timestamp\": \"T1\"}]}\n{\"data\": [{\"account\": \"B\", \"amount\": 200, \"block\": 2, \"gateway\": \"G2\", \"hash\": \"H2\", \"timestamp\": \"T2\"}]}\n{\"data\": [{\"account\": \"A\", \"amount\": 100, \"block\": 1, \"gateway\": \"G1\", \"hash\": \"H1\", \"timestamp\": \"T1\"}]}","validation_output":"[\n {\n \"account\": \"A\",\n \"amount\": 100,\n \"block\": 1,\n \"gateway\": \"G1\",\n \"hash\": \"H1\",\n \"timestamp\": \"T1\"\n },\n {\n \"account\": \"B\",\n \"amount\": 200,\n \"block\": 2,\n \"gateway\": \"G2\",\n \"hash\": \"H2\",\n \"timestamp\": \"T2\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70015029/get-unique-objects-and-arrays-based-on-key-value","question_title":"Get unique objects and arrays based on key value","question_owner":"Nick Hatfield","answer_owner":"peak","answer_id":70016167,"question_score":5,"reviewed":true,"paraphrase_of":"so-70015029","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-70187417","request":"Find the group containing 'Service A' in its orgs array and return only the first recipient object from that group.","command":"jq '.groups[] | select(.orgs | index(\"Service A\")) | .recipients | first'","input_text":"{\n \"default\": [\n {\n \"name\": \"Joe Bloggs\",\n \"email\": \"joe.bloggs@business.org\"\n }\n ],\n \"groups\": [\n {\n \"recipients\": [\n {\n \"name\": \"Jane Bloggs\",\n \"email\": \"jane.bloggs@business.org\"\n }\n ],\n \"orgs\": [\n \"Service A\",\n \"Service B\",\n \"Service C\"\n ]\n },\n {\n \"recipients\": [\n {\n \"name\": \"Bill Gates\",\n \"email\": \"bill.gates@business.org\"\n }\n ],\n \"orgs\": [\n \"Service D\",\n \"Service E\"\n ]\n }\n ]\n}","expected_output":"{\n \"name\": \"Jane Bloggs\",\n \"email\": \"jane.bloggs@business.org\"\n}\n","validation_input":"{\n \"default\": [],\n \"groups\": [\n {\n \"recipients\": [\n {\n \"name\": \"Alice Smith\",\n \"email\": \"alice@example.com\"\n }\n ],\n \"orgs\": [\n \"Service X\",\n \"Service A\"\n ]\n }\n ]\n}","validation_output":"{\n \"name\": \"Alice Smith\",\n \"email\": \"alice@example.com\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70187417/array-and-string-cannot-have-their-containment-checked-error-when-trying-to-sear","question_title":"Array and String cannot have their containment checked error when trying to search array using jq","question_owner":"yungblazeboy","answer_owner":"0stone0","answer_id":70188269,"question_score":8,"reviewed":true} {"id":"so-70187417-p1","request":"Locate the group listing 'Service A' in its orgs array and return only the first recipient object from that group.","command":"jq '.groups[] | select(.orgs | index(\"Service A\")) | .recipients | first'","input_text":"{\n \"default\": [\n {\n \"name\": \"Joe Bloggs\",\n \"email\": \"joe.bloggs@business.org\"\n }\n ],\n \"groups\": [\n {\n \"recipients\": [\n {\n \"name\": \"Jane Bloggs\",\n \"email\": \"jane.bloggs@business.org\"\n }\n ],\n \"orgs\": [\n \"Service A\",\n \"Service B\",\n \"Service C\"\n ]\n },\n {\n \"recipients\": [\n {\n \"name\": \"Bill Gates\",\n \"email\": \"bill.gates@business.org\"\n }\n ],\n \"orgs\": [\n \"Service D\",\n \"Service E\"\n ]\n }\n ]\n}","expected_output":"{\n \"name\": \"Jane Bloggs\",\n \"email\": \"jane.bloggs@business.org\"\n}\n","validation_input":"{\n \"default\": [],\n \"groups\": [\n {\n \"recipients\": [\n {\n \"name\": \"Alice Smith\",\n \"email\": \"alice@example.com\"\n }\n ],\n \"orgs\": [\n \"Service X\",\n \"Service A\"\n ]\n }\n ]\n}","validation_output":"{\n \"name\": \"Alice Smith\",\n \"email\": \"alice@example.com\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70187417/array-and-string-cannot-have-their-containment-checked-error-when-trying-to-sear","question_title":"Array and String cannot have their containment checked error when trying to search array using jq","question_owner":"yungblazeboy","answer_owner":"0stone0","answer_id":70188269,"question_score":8,"reviewed":true,"paraphrase_of":"so-70187417","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-70255282","request":"Remove objects from the 'data' array where the 'hash' key equals '0M0fudEmzW9dmAsO3dcWT286tTL6wTX9sllXtsyz-0Q'.","command":"jq 'del(.data[] | select(.hash == \"0M0fudEmzW9dmAsO3dcWT286tTL6wTX9sllXtsyz-0Q\"))'","input_text":"{\"data\":[{\"account\":\"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\"gateway\":\"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\"hash\":\"DTU1GGfR0eU15hv6KiV_bg6FOJXfUWz4TjIq1H7TGy4\",\"timestamp\":\"2020-08-28T01:29:46.000000Z\"},{\"account\":\"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\"gateway\":\"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\"hash\":\"l3EQR6AJ6R1qE1meHyafDnNF8vJ-X-rH1pujxQRTds4\",\"timestamp\":\"2020-08-28T00:50:44.000000Z\"},{\"account\":\"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\"gateway\":\"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\"hash\":\"5fQJY9MprH9b3IstVU1SdfBteUWoF_sdsVuiARPBtTY\",\"timestamp\":\"2020-08-27T19:01:48.000000Z\"},{\"account\":\"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\"gateway\":\"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\"hash\":\"0M0fudEmzW9dmAsO3dcWT286tTL6wTX9sllXtsyz-0Q\",\"timestamp\":\"2020-08-27T18:15:17.000000Z\"}]}","expected_output":"{\n \"data\": [\n {\n \"account\": \"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\n \"gateway\": \"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\n \"hash\": \"DTU1GGfR0eU15hv6KiV_bg6FOJXfUWz4TjIq1H7TGy4\",\n \"timestamp\": \"2020-08-28T01:29:46.000000Z\"\n },\n {\n \"account\": \"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\n \"gateway\": \"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\n \"hash\": \"l3EQR6AJ6R1qE1meHyafDnNF8vJ-X-rH1pujxQRTds4\",\n \"timestamp\": \"2020-08-28T00:50:44.000000Z\"\n },\n {\n \"account\": \"12xUoMKwf12ABjNx4VCvYcNkX79gW1kzz2JnBLxkFbjswRczRvM\",\n \"gateway\": \"113kQU96zqePySTahB7PEde9ZpoWK76DYK1f57wyhjhXCBoAu88\",\n \"hash\": \"5fQJY9MprH9b3IstVU1SdfBteUWoF_sdsVuiARPBtTY\",\n \"timestamp\": \"2020-08-27T19:01:48.000000Z\"\n }\n ]\n}\n","validation_input":"{\"data\":[{\"account\":\"acc1\",\"gateway\":\"gw1\",\"hash\":\"keep1\",\"timestamp\":\"2020-01-01T00:00:00.000000Z\"},{\"account\":\"acc2\",\"gateway\":\"gw2\",\"hash\":\"0M0fudEmzW9dmAsO3dcWT286tTL6wTX9sllXtsyz-0Q\",\"timestamp\":\"2020-01-02T00:00:00.000000Z\"},{\"account\":\"acc3\",\"gateway\":\"gw3\",\"hash\":\"keep3\",\"timestamp\":\"2020-01-03T00:00:00.000000Z\"}]}","validation_output":"{\n \"data\": [\n {\n \"account\": \"acc1\",\n \"gateway\": \"gw1\",\n \"hash\": \"keep1\",\n \"timestamp\": \"2020-01-01T00:00:00.000000Z\"\n },\n {\n \"account\": \"acc3\",\n \"gateway\": \"gw3\",\n \"hash\": \"keep3\",\n \"timestamp\": \"2020-01-03T00:00:00.000000Z\"\n }\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/70255282/jq-remove-objects-based-on-key-value","question_title":"JQ remove objects based on key value","question_owner":"Nick Hatfield","answer_owner":"Barbaros Özhan","answer_id":70255965,"question_score":8,"reviewed":true} {"id":"so-71074096","request":"Sort the bill_rates arrays within each employee_observations object by percentage in descending order, while preserving the rest of the JSON structure.","command":"jq '.[].employee_observations[].bill_rates |= sort_by(-.percentage)'","input_text":"[{\"id\": 2, \"employee_observations\": [{\"id\": 1, \"bill_rates\": [{\"bill_classification\": \"Lawn Mowing\", \"percentage\": 0.67}, {\"bill_classification\": \"Trimming\", \"percentage\": 0.001}, {\"bill_classification\": \"Snow Removal\", \"percentage\": 0.63}]}]}]","expected_output":"[\n {\n \"id\": 2,\n \"employee_observations\": [\n {\n \"id\": 1,\n \"bill_rates\": [\n {\n \"bill_classification\": \"Lawn Mowing\",\n \"percentage\": 0.67\n },\n {\n \"bill_classification\": \"Snow Removal\",\n \"percentage\": 0.63\n },\n {\n \"bill_classification\": \"Trimming\",\n \"percentage\": 0.001\n }\n ]\n }\n ]\n }\n]\n","validation_input":"[{\"id\": 5, \"employee_observations\": [{\"id\": 10, \"bill_rates\": [{\"bill_classification\": \"A\", \"percentage\": 0.1}, {\"bill_classification\": \"B\", \"percentage\": 0.9}, {\"bill_classification\": \"C\", \"percentage\": 0.5}]}]}]","validation_output":"[\n {\n \"id\": 5,\n \"employee_observations\": [\n {\n \"id\": 10,\n \"bill_rates\": [\n {\n \"bill_classification\": \"B\",\n \"percentage\": 0.9\n },\n {\n \"bill_classification\": \"C\",\n \"percentage\": 0.5\n },\n {\n \"bill_classification\": \"A\",\n \"percentage\": 0.1\n }\n ]\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/71074096/sort-array-inside-a-nested-object-while-maintaining-the-original-json-object","question_title":"Sort array inside a nested object while maintaining the original json object","question_owner":"cbetsworth_echo","answer_owner":"pmf","answer_id":71074149,"question_score":5,"reviewed":true} {"id":"so-71074096-p1","request":"Sort the bill_rates arrays inside each employee_observations object by percentage in descending order, keeping the rest of the JSON intact.","command":"jq '.[].employee_observations[].bill_rates |= sort_by(-.percentage)'","input_text":"[{\"id\": 2, \"employee_observations\": [{\"id\": 1, \"bill_rates\": [{\"bill_classification\": \"Lawn Mowing\", \"percentage\": 0.67}, {\"bill_classification\": \"Trimming\", \"percentage\": 0.001}, {\"bill_classification\": \"Snow Removal\", \"percentage\": 0.63}]}]}]","expected_output":"[\n {\n \"id\": 2,\n \"employee_observations\": [\n {\n \"id\": 1,\n \"bill_rates\": [\n {\n \"bill_classification\": \"Lawn Mowing\",\n \"percentage\": 0.67\n },\n {\n \"bill_classification\": \"Snow Removal\",\n \"percentage\": 0.63\n },\n {\n \"bill_classification\": \"Trimming\",\n \"percentage\": 0.001\n }\n ]\n }\n ]\n }\n]\n","validation_input":"[{\"id\": 5, \"employee_observations\": [{\"id\": 10, \"bill_rates\": [{\"bill_classification\": \"A\", \"percentage\": 0.1}, {\"bill_classification\": \"B\", \"percentage\": 0.9}, {\"bill_classification\": \"C\", \"percentage\": 0.5}]}]}]","validation_output":"[\n {\n \"id\": 5,\n \"employee_observations\": [\n {\n \"id\": 10,\n \"bill_rates\": [\n {\n \"bill_classification\": \"B\",\n \"percentage\": 0.9\n },\n {\n \"bill_classification\": \"C\",\n \"percentage\": 0.5\n },\n {\n \"bill_classification\": \"A\",\n \"percentage\": 0.1\n }\n ]\n }\n ]\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/71074096/sort-array-inside-a-nested-object-while-maintaining-the-original-json-object","question_title":"Sort array inside a nested object while maintaining the original json object","question_owner":"cbetsworth_echo","answer_owner":"pmf","answer_id":71074149,"question_score":5,"reviewed":true,"paraphrase_of":"so-71074096","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-72801812","request":"Extract an array of names from a JSON array where elements are either objects with a \"name\" key or plain strings. For objects, use the value of the \"name\" key; for strings, use the string itself.","command":"jq '[ .[] | .name? // . ]'","input_text":"[{\"name\":\"NAME_1\"},\"NAME_2\"]","expected_output":"[\n \"NAME_1\",\n \"NAME_2\"\n]\n","validation_input":"[{\"name\":\"Alice\"},{\"name\":\"Bob\"},\"Charlie\"]","validation_output":"[\n \"Alice\",\n \"Bob\",\n \"Charlie\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/72801812/get-value-if-object-or-string-if-string-in-jq-array","question_title":"Get value if object or string if string in jq array","question_owner":"Saddy","answer_owner":"glenn jackman","answer_id":72801992,"question_score":5,"reviewed":true} {"id":"so-72801812-p1","request":"Generate an array of names from a mixed list of strings and objects; for objects, take the 'name' value, and for strings, use the value directly.","command":"jq '[ .[] | .name? // . ]'","input_text":"[{\"name\":\"NAME_1\"},\"NAME_2\"]","expected_output":"[\n \"NAME_1\",\n \"NAME_2\"\n]\n","validation_input":"[{\"name\":\"Alice\"},{\"name\":\"Bob\"},\"Charlie\"]","validation_output":"[\n \"Alice\",\n \"Bob\",\n \"Charlie\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/72801812/get-value-if-object-or-string-if-string-in-jq-array","question_title":"Get value if object or string if string in jq array","question_owner":"Saddy","answer_owner":"glenn jackman","answer_id":72801992,"question_score":5,"reviewed":true,"paraphrase_of":"so-72801812","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-73716917","request":"For every object in the JSON structure that has a key named 'base', add a new key 'path' to that same object. The value of 'path' should be the dot-separated path to the 'base' key itself.","command":"jq 'reduce paths(objects | has(\"base\")) as $p (.; setpath($p + [\"path\"]; ($p + [\"base\"]) | join(\".\")))'","input_text":"{\n \"entity\": {\n \"product\": {\n \"att\": {\n \"number_of_values\": \"Number of values\"\n },\n \"title\": {\n \"base\": [\n \"product\",\n \"products\"\n ]\n }\n }\n }\n}","expected_output":"{\n \"entity\": {\n \"product\": {\n \"att\": {\n \"number_of_values\": \"Number of values\"\n },\n \"title\": {\n \"base\": [\n \"product\",\n \"products\"\n ],\n \"path\": \"entity.product.title.base\"\n }\n }\n }\n}\n","validation_input":"{\n \"a\": {\n \"b\": {\n \"base\": [\n 1,\n 2\n ]\n }\n }\n}","validation_output":"{\n \"a\": {\n \"b\": {\n \"base\": [\n 1,\n 2\n ],\n \"path\": \"a.b.base\"\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/73716917/use-jq-to-get-all-parent-keys-of-specific-key","question_title":"Use jq to get all parent keys of specific key","question_owner":"Max","answer_owner":"oguz ismail","answer_id":73717316,"question_score":5,"reviewed":true} {"id":"so-73716917-p1","request":"For every object possessing a 'base' key, append a 'path' key containing the dot-separated path to that 'base' key.","command":"jq 'reduce paths(objects | has(\"base\")) as $p (.; setpath($p + [\"path\"]; ($p + [\"base\"]) | join(\".\")))'","input_text":"{\n \"entity\": {\n \"product\": {\n \"att\": {\n \"number_of_values\": \"Number of values\"\n },\n \"title\": {\n \"base\": [\n \"product\",\n \"products\"\n ]\n }\n }\n }\n}","expected_output":"{\n \"entity\": {\n \"product\": {\n \"att\": {\n \"number_of_values\": \"Number of values\"\n },\n \"title\": {\n \"base\": [\n \"product\",\n \"products\"\n ],\n \"path\": \"entity.product.title.base\"\n }\n }\n }\n}\n","validation_input":"{\n \"a\": {\n \"b\": {\n \"base\": [\n 1,\n 2\n ]\n }\n }\n}","validation_output":"{\n \"a\": {\n \"b\": {\n \"base\": [\n 1,\n 2\n ],\n \"path\": \"a.b.base\"\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/73716917/use-jq-to-get-all-parent-keys-of-specific-key","question_title":"Use jq to get all parent keys of specific key","question_owner":"Max","answer_owner":"oguz ismail","answer_id":73717316,"question_score":5,"reviewed":true,"paraphrase_of":"so-73716917","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-74400075","request":"Select and output individual objects from a JSON array where the 'title' field contains the substring 'Star'.","command":"jq '.[] | select(.title | contains(\"Star\"))'","input_text":"[\n {\n \"title\": \"Dark Knight, The\",\n \"year\": 2008\n },\n {\n \"title\": \"Star Trek Beyond\",\n \"year\": 2016\n },\n {\n \"title\": \"Star Wars: Episode VII - The Force Awakens\",\n \"year\": 2015\n }\n]","expected_output":"{\n \"title\": \"Star Trek Beyond\",\n \"year\": 2016\n}\n{\n \"title\": \"Star Wars: Episode VII - The Force Awakens\",\n \"year\": 2015\n}\n","validation_input":"[\n {\n \"title\": \"Inception\",\n \"year\": 2010\n },\n {\n \"title\": \"Interstellar\",\n \"year\": 2014\n },\n {\n \"title\": \"Stardust\",\n \"year\": 2007\n },\n {\n \"title\": \"The Matrix\",\n \"year\": 1999\n }\n]","validation_output":"{\n \"title\": \"Stardust\",\n \"year\": 2007\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/74400075/how-to-select-based-on-a-substring-in-jq","question_title":"how to select based on a substring in jq","question_owner":"rusheb","answer_owner":"rusheb","answer_id":74400076,"question_score":7,"reviewed":true} {"id":"so-74400075-p1","request":"Output individual objects from a JSON array where the 'title' field contains the substring 'Star'.","command":"jq '.[] | select(.title | contains(\"Star\"))'","input_text":"[\n {\n \"title\": \"Dark Knight, The\",\n \"year\": 2008\n },\n {\n \"title\": \"Star Trek Beyond\",\n \"year\": 2016\n },\n {\n \"title\": \"Star Wars: Episode VII - The Force Awakens\",\n \"year\": 2015\n }\n]","expected_output":"{\n \"title\": \"Star Trek Beyond\",\n \"year\": 2016\n}\n{\n \"title\": \"Star Wars: Episode VII - The Force Awakens\",\n \"year\": 2015\n}\n","validation_input":"[\n {\n \"title\": \"Inception\",\n \"year\": 2010\n },\n {\n \"title\": \"Interstellar\",\n \"year\": 2014\n },\n {\n \"title\": \"Stardust\",\n \"year\": 2007\n },\n {\n \"title\": \"The Matrix\",\n \"year\": 1999\n }\n]","validation_output":"{\n \"title\": \"Stardust\",\n \"year\": 2007\n}\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/74400075/how-to-select-based-on-a-substring-in-jq","question_title":"how to select based on a substring in jq","question_owner":"rusheb","answer_owner":"rusheb","answer_id":74400076,"question_score":7,"reviewed":true,"paraphrase_of":"so-74400075","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-75769972","request":"Check if the nested key 'b' exists within the object at key 'a' in the input JSON.","command":"jq '.a | has(\"b\")'","input_text":"{\"a\":{\"b\":\"hello\"}}","expected_output":"true\n","validation_input":"{\"a\":{\"c\":\"world\"}}","validation_output":"false\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/75769972/possible-to-use-has-with-nested-keys","question_title":"Possible to use has() with nested keys?","question_owner":"art vanderlay","answer_owner":"pmf","answer_id":75770006,"question_score":6,"reviewed":true} {"id":"so-75769972-p1","request":"Verify whether the key 'b' exists within the object located at key 'a' in the input JSON.","command":"jq '.a | has(\"b\")'","input_text":"{\"a\":{\"b\":\"hello\"}}","expected_output":"true\n","validation_input":"{\"a\":{\"c\":\"world\"}}","validation_output":"false\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/75769972/possible-to-use-has-with-nested-keys","question_title":"Possible to use has() with nested keys?","question_owner":"art vanderlay","answer_owner":"pmf","answer_id":75770006,"question_score":6,"reviewed":true,"paraphrase_of":"so-75769972","paraphrase_model":"qwen/qwen3.7-plus"} {"id":"so-75952221","request":"Extract the value of the field 'pod-security.kubernetes.io/audit-violations' from the 'annotations' object in each JSON record, filtering out any null results.","command":"jq -r '.annotations.\"pod-security.kubernetes.io/audit-violations\" | values'","input_text":"{\"kind\":\"Event\",\"annotations\":{\"authorization.k8s.io/decision\":\"allow\",\"pod-security.kubernetes.io/audit-violations\":\"would violate PodSecurity\"}}\n{\"kind\":\"Event\",\"annotations\":{\"authorization.k8s.io/decision\":\"allow\"}}\n{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":null}}","expected_output":"would violate PodSecurity\n","validation_input":"{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":\"error: unrestricted capabilities\"}}\n{\"kind\":\"Event\",\"annotations\":{}}\n{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":\"error: seccompProfile\"}}","validation_output":"error: unrestricted capabilities\nerror: seccompProfile\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/75952221/how-to-remove-null-values-while-extracting-data-with-jq","question_title":"How to remove null values while extracting data with jq?","question_owner":"Starbucks Admin","answer_owner":"pmf","answer_id":75952611,"question_score":5,"reviewed":true} {"id":"so-75952221-p1","request":"Extract the 'pod-security.kubernetes.io/audit-violations' value from the 'annotations' object in each record, excluding any null results.","command":"jq -r '.annotations.\"pod-security.kubernetes.io/audit-violations\" | values'","input_text":"{\"kind\":\"Event\",\"annotations\":{\"authorization.k8s.io/decision\":\"allow\",\"pod-security.kubernetes.io/audit-violations\":\"would violate PodSecurity\"}}\n{\"kind\":\"Event\",\"annotations\":{\"authorization.k8s.io/decision\":\"allow\"}}\n{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":null}}","expected_output":"would violate PodSecurity\n","validation_input":"{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":\"error: unrestricted capabilities\"}}\n{\"kind\":\"Event\",\"annotations\":{}}\n{\"kind\":\"Event\",\"annotations\":{\"pod-security.kubernetes.io/audit-violations\":\"error: seccompProfile\"}}","validation_output":"error: unrestricted capabilities\nerror: seccompProfile\n","family":"real-stackoverflow","difficulty":3,"split":"train","source":"openrouter-paraphrase","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/75952221/how-to-remove-null-values-while-extracting-data-with-jq","question_title":"How to remove null values while extracting data with jq?","question_owner":"Starbucks Admin","answer_owner":"pmf","answer_id":75952611,"question_score":5,"reviewed":true,"paraphrase_of":"so-75952221","paraphrase_model":"qwen/qwen3.7-plus"}