asterbraid commited on
Commit
837bf81
·
verified ·
1 Parent(s): 0fe31f4

Jqweave: 50 reviewed real Stack Overflow tasks with held-out model evaluation

Browse files
ATTRIBUTION.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Source attribution
2
+
3
+ - [Select objects based on value of variable in object using jq](https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq) — question: Daniel; accepted answer: Daniel (answer 18608100).
4
+
5
+ - [Parsing JSON with Unix tools](https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools) — question: auser; accepted answer: Brian Campbell (answer 1955555).
6
+
7
+ - [jq Conditional output](https://stackoverflow.com/questions/19573517/jq-conditional-output) — question: clwen; accepted answer: max taldykin (answer 20489951).
8
+
9
+ - [How to map an object to arrays so it can be converted to csv?](https://stackoverflow.com/questions/20181467/how-to-map-an-object-to-arrays-so-it-can-be-converted-to-csv) — question: lsl; accepted answer: Jeff Mercado (answer 24254365).
10
+
11
+ - [How to count items in JSON object using command line?](https://stackoverflow.com/questions/21334348/how-to-count-items-in-json-object-using-command-line) — question: Édouard Lopez; accepted answer: Ken (answer 21355442).
12
+
13
+ - [How to get key names from JSON using jq](https://stackoverflow.com/questions/23118341/how-to-get-key-names-from-json-using-jq) — question: Ezhilan Mahalingam; accepted answer: anubhava (answer 23118607).
14
+
15
+ - [Flatten a JSON document using jq](https://stackoverflow.com/questions/24698188/flatten-a-json-document-using-jq) — question: Dror; accepted answer: Jeff Mercado (answer 24710337).
16
+
17
+ - [How to convert a JSON object to key=value format in jq?](https://stackoverflow.com/questions/25378013/how-to-convert-a-json-object-to-key-value-format-in-jq) — question: gianebao; accepted answer: aioobe (answer 25378171).
18
+
19
+ - [jq: how to filter an array of objects based on values in an inner array?](https://stackoverflow.com/questions/26701538/jq-how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array) — question: Abe Voelker; accepted answer: Iain Samuel McLean Elder (answer 26701851).
20
+
21
+ - [jq: nested object, extract top-level id and lift a value from internal object](https://stackoverflow.com/questions/27562424/jq-nested-object-extract-top-level-id-and-lift-a-value-from-internal-object) — question: tripleee; accepted answer: tripleee (answer 27562901).
22
+
23
+ - [How do I sum the values in an array of maps in jq?](https://stackoverflow.com/questions/28484534/how-do-i-sum-the-values-in-an-array-of-maps-in-jq) — question: Alan Burlison; accepted answer: Jeff Mercado (answer 28485485).
24
+
25
+ - [How to convert a JSON object stream into an array with jq](https://stackoverflow.com/questions/29404575/how-to-convert-a-json-object-stream-into-an-array-with-jq) — question: Qiang Li; accepted answer: Jeff Mercado (answer 29404613).
26
+
27
+ - [JSON JQ if without else](https://stackoverflow.com/questions/29949184/json-jq-if-without-else) — question: user1578872; accepted answer: peak (answer 29962258).
28
+
29
+ - [How do I update a single value in a json document using jq?](https://stackoverflow.com/questions/31034746/how-do-i-update-a-single-value-in-a-json-document-using-jq) — question: STW; accepted answer: Jeff Mercado (answer 31037640).
30
+
31
+ - [How to use `jq` in a shell pipeline?](https://stackoverflow.com/questions/33247228/how-to-use-jq-in-a-shell-pipeline) — question: mgalgs; accepted answer: chepner (answer 33247259).
32
+
33
+ - [Exclude column from jq json output](https://stackoverflow.com/questions/33895076/exclude-column-from-jq-json-output) — question: Leo Gallucci; accepted answer: hek2mgl (answer 33895231).
34
+
35
+ - [Concat numbers from JSON without doublequotes using jq](https://stackoverflow.com/questions/33947584/concat-numbers-from-json-without-doublequotes-using-jq) — question: Synesso; accepted answer: xjedam (answer 33952189).
36
+
37
+ - [jq: print key and value for each entry in an object](https://stackoverflow.com/questions/34226370/jq-print-key-and-value-for-each-entry-in-an-object) — question: Jeff Tang; accepted answer: peak (answer 34227629).
38
+
39
+ - [Convert string to json in jq](https://stackoverflow.com/questions/34340549/convert-string-to-json-in-jq) — question: RJ-Adam; accepted answer: Jeff Mercado (answer 34340787).
40
+
41
+ - [jq: Cannot index array with string](https://stackoverflow.com/questions/34543829/jq-cannot-index-array-with-string) — question: Xu Wang; accepted answer: hek2mgl (answer 34544406).
42
+
43
+ - [jq - How to iterate through keys of different names](https://stackoverflow.com/questions/35086391/jq-how-to-iterate-through-keys-of-different-names) — question: Adam vonNieda; accepted answer: peak (answer 35091473).
44
+
45
+ - [how to parse a JSON String with jq (or other alternatives)?](https://stackoverflow.com/questions/35154684/how-to-parse-a-json-string-with-jq-or-other-alternatives) — question: Colin Grogan; accepted answer: jwodder (answer 35155249).
46
+
47
+ - [Output specific key value in object for each element in array with jq for JSON](https://stackoverflow.com/questions/35677309/output-specific-key-value-in-object-for-each-element-in-array-with-jq-for-json) — question: Zimbabwe Elephant; accepted answer: peak (answer 35677443).
48
+
49
+ - [Deleting multiple keys at once with jq](https://stackoverflow.com/questions/36227245/deleting-multiple-keys-at-once-with-jq) — question: antun; accepted answer: user3899165 (answer 36228054).
50
+
51
+ - [jq not working on tag name with dashes and numbers](https://stackoverflow.com/questions/37344329/jq-not-working-on-tag-name-with-dashes-and-numbers) — question: paul; accepted answer: fedorqui (answer 37344498).
52
+
53
+ - [jq select value from array](https://stackoverflow.com/questions/37563691/jq-select-value-from-array) — question: Marvin Effing; accepted answer: Marvin Effing (answer 37567004).
54
+
55
+ - [How to use `jq` to obtain the keys](https://stackoverflow.com/questions/37577683/how-to-use-jq-to-obtain-the-keys) — question: sudhishkr; accepted answer: Andreas Louv (answer 37577805).
56
+
57
+ - [Concat 2 fields in JSON using jq](https://stackoverflow.com/questions/37710718/concat-2-fields-in-json-using-jq) — question: darthsidious; accepted answer: Anthony Battaglia (answer 37710802).
58
+
59
+ - [jq: output array of json objects](https://stackoverflow.com/questions/38061346/jq-output-array-of-json-objects) — question: Mauricio Trajano; accepted answer: chepner (answer 38061430).
60
+
61
+ - [How to filter array of objects by element property values using jq?](https://stackoverflow.com/questions/38121740/how-to-filter-array-of-objects-by-element-property-values-using-jq) — question: k0pernikus; accepted answer: André Senra (answer 38122029).
62
+
63
+ - [get the first (or n'th) element in a jq json parsing](https://stackoverflow.com/questions/38500363/get-the-first-or-nth-element-in-a-jq-json-parsing) — question: Demian Glait; accepted answer: hek2mgl (answer 38500610).
64
+
65
+ - [How do I print a parent value of an object when I am already deep into the object's children?](https://stackoverflow.com/questions/38689645/how-do-i-print-a-parent-value-of-an-object-when-i-am-already-deep-into-the-objec) — question: x3nr0s; accepted answer: user3899165 (answer 38693695).
66
+
67
+ - [Extract a specific field from JSON output using jq](https://stackoverflow.com/questions/39228500/extract-a-specific-field-from-json-output-using-jq) — question: rmb; accepted answer: aaaaaa123456789 (answer 39228718).
68
+
69
+ - [Get outputs from jq on a single line](https://stackoverflow.com/questions/40396445/get-outputs-from-jq-on-a-single-line) — question: Jitesh Sojitra; accepted answer: hmedia1 (answer 40396556).
70
+
71
+ - [Pattern matching field names with jq](https://stackoverflow.com/questions/42051601/pattern-matching-field-names-with-jq) — question: manu; accepted answer: koalo (answer 42051804).
72
+
73
+ - [Add new element to existing JSON array with jq](https://stackoverflow.com/questions/42245288/add-new-element-to-existing-json-array-with-jq) — question: Felipe; accepted answer: Inian (answer 42248841).
74
+
75
+ - [Using jq, convert array of objects to object with named keys](https://stackoverflow.com/questions/42427725/using-jq-convert-array-of-objects-to-object-with-named-keys) — question: Mike N; accepted answer: peak (answer 42428341).
76
+
77
+ - [jq: how to query for array values that don't contain text "foo"?](https://stackoverflow.com/questions/42746828/jq-how-to-query-for-array-values-that-dont-contain-text-foo) — question: Gavriel Fishel; accepted answer: J. Doe (answer 42747910).
78
+
79
+ - [jq: group and key by property](https://stackoverflow.com/questions/43221453/jq-group-and-key-by-property) — question: replay; accepted answer: replay (answer 43221520).
80
+
81
+ - [using jq to assign multiple output variables](https://stackoverflow.com/questions/43291389/using-jq-to-assign-multiple-output-variables) — question: user2328273; accepted answer: Bertrand Martel (answer 43293515).
82
+
83
+ - [Using jq how can I replace the name of a key with something else](https://stackoverflow.com/questions/43522133/using-jq-how-can-i-replace-the-name-of-a-key-with-something-else) — question: user486670; accepted answer: RomanPerekhrest (answer 43522716).
84
+
85
+ - [How to remove double-quotes in jq output for parsing json files in bash?](https://stackoverflow.com/questions/44656515/how-to-remove-double-quotes-in-jq-output-for-parsing-json-files-in-bash) — question: Chris F; accepted answer: Charles Duffy (answer 44656583).
86
+
87
+ - [How to combine an array into a single string value when using CSV output in jq?](https://stackoverflow.com/questions/45165303/how-to-combine-an-array-into-a-single-string-value-when-using-csv-output-in-jq) — question: Emre Sevinç; accepted answer: zwer (answer 45165687).
88
+
89
+ - [getting all the values of an array with jq](https://stackoverflow.com/questions/45523425/getting-all-the-values-of-an-array-with-jq) — question: Miss Alena; accepted answer: peak (answer 45524015).
90
+
91
+ - [Printing multiple values on the same line](https://stackoverflow.com/questions/46131727/printing-multiple-values-on-the-same-line) — question: Mickster; accepted answer: jq170727 (answer 46131963).
92
+
93
+ - [Removing a key from parent object with jq](https://stackoverflow.com/questions/47023795/removing-a-key-from-parent-object-with-jq) — question: Nicholas; accepted answer: jq170727 (answer 47024050).
94
+
95
+ - [How to extract a field from each object in an array with jq?](https://stackoverflow.com/questions/48426052/how-to-extract-a-field-from-each-object-in-an-array-with-jq) — question: Chris F; accepted answer: John Kugelman (answer 48426543).
96
+
97
+ - [How to add a field to a JSON object with the jq command?](https://stackoverflow.com/questions/49632521/how-to-add-a-field-to-a-json-object-with-the-jq-command) — question: Joe; accepted answer: peak (answer 49632947).
98
+
99
+ - [Filter by Regex in JQ](https://stackoverflow.com/questions/50868203/filter-by-regex-in-jq) — question: user49; accepted answer: peak (answer 50868294).
100
+
101
+ - [How do I sum all numbers from output of jq](https://stackoverflow.com/questions/52065570/how-do-i-sum-all-numbers-from-output-of-jq) — question: toy; accepted answer: Charles Duffy (answer 52065738).
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-4.0
3
+ language: en
4
+ pretty_name: Jqweave Real Questions
5
+ size_categories:
6
+ - n<1K
7
+ task_categories:
8
+ - text-generation
9
+ tags:
10
+ - jq
11
+ - json
12
+ - code-generation
13
+ - text-to-code
14
+ - execution-verified
15
+ - stackoverflow
16
+ configs:
17
+ - config_name: default
18
+ data_files:
19
+ - split: test
20
+ path: data/test.jsonl
21
+ ---
22
+
23
+ # Jqweave Real Questions
24
+
25
+ A held-out natural-language-to-`jq` evaluation set derived from highly voted Stack Overflow questions and accepted answers. It tests whether Jqweave generalizes beyond the phrasing and task distribution of its synthetic training data.
26
+
27
+ ## Contents
28
+
29
+ - 50 manually reviewed tasks from 50 unique source questions.
30
+ - Two different representative inputs per task, with actual outputs from both.
31
+ - Every task is in the `test` split; no paraphrases or training rows are included.
32
+ - Zero input-text or request/command overlap with `asterbraid/jqweave-data`.
33
+
34
+ Every reference command was executed on both inputs with `jq-1.6`: **100 successful executions, 0 errors**. Commands start with `jq`, read one JSON stream on stdin, and avoid filenames, modules, environment access, additional inputs, and shell execution.
35
+
36
+ ## Source and attribution
37
+
38
+ Each row includes `question_url`, `question_title`, `question_owner`, `answer_owner`, and `answer_id`. `ATTRIBUTION.md` lists every source. The `request` is a self-contained instruction derived from the question and accepted answer; `command` is an executable solution. Request-to-command intent was manually reviewed in addition to execution verification.
39
+
40
+ ```python
41
+ from datasets import load_dataset
42
+
43
+ ds = load_dataset("asterbraid/jqweave-so-data", split="test")
44
+ print(ds[0])
45
+ ```
46
+
47
+ ## Public model evaluation
48
+
49
+ Greedy generation with `asterbraid/jqweave-0.5b`; one prediction per task. Valid means the generated command executes. Correct requires exact expected output on both inputs, with only trailing special tokens removed.
50
+
51
+ | Model | Valid | Correct |
52
+ | --- | ---: | ---: |
53
+ | Jqweave 0.5B | 54.0% (27/50) | 10.0% (5/50) |
54
+
55
+ Full predictions and the summary are included under `evaluation/`.
56
+
57
+
58
+ ## Limitations
59
+
60
+ This is a small, high-vote sample, not a representative benchmark of all `jq` use. Tasks were selected for compatibility with single-stream input and the safety guard. Exact outputs on two synthetic representative inputs do not prove correctness on every possible input. Some requests or commands may be ambiguous outside their original context.
61
+
62
+ ## License
63
+
64
+ Original Stack Overflow content and these derived rows are **CC BY-SA 4.0**. See `SO_DATASET_LICENSE.txt` and `ATTRIBUTION.md`. Included collection, conversion, review, and validation code is Apache-2.0.
SO_DATASET_LICENSE.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Awkweave Stack Overflow-derived rows are licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).
2
+
3
+ The rows are derived from Stack Overflow questions and accepted answers. Each row includes the question URL, question title, question author, answer author, and answer ID. The original questions and answers remain the work of their respective authors. Listings and generated attribution files in this repository are provided by Asterbraid.
4
+
5
+ You must give appropriate credit, link to the license, indicate changes, and distribute adaptations under the same license.
6
+
7
+ License: https://creativecommons.org/licenses/by-sa/4.0/
8
+ Legal code: https://creativecommons.org/licenses/by-sa/4.0/legalcode
9
+ Stack Exchange content policy: https://stackoverflow.com/legal/terms-of-service/public
convert_real_questions.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import concurrent.futures
5
+ import html
6
+ import html.parser
7
+ import json
8
+ import os
9
+ import time
10
+ import urllib.request
11
+ from pathlib import Path
12
+
13
+ from jqweave.execution import run_jq
14
+
15
+ MODEL = "qwen/qwen3.7-plus"
16
+
17
+
18
+ class TextExtractor(html.parser.HTMLParser):
19
+ def __init__(self):
20
+ super().__init__()
21
+ self.parts = []
22
+ self.skip = 0
23
+
24
+ def handle_starttag(self, tag, attrs):
25
+ if tag in {"script", "style"}:
26
+ self.skip += 1
27
+ if tag in {"p", "br", "pre", "code", "li", "tr"}:
28
+ self.parts.append("\n")
29
+
30
+ def handle_endtag(self, tag):
31
+ if tag in {"script", "style"} and self.skip:
32
+ self.skip -= 1
33
+ if tag in {"p", "pre", "code", "li", "tr"}:
34
+ self.parts.append("\n")
35
+
36
+ def handle_data(self, data):
37
+ if not self.skip:
38
+ self.parts.append(data)
39
+
40
+
41
+ def plain(value: str) -> str:
42
+ parser = TextExtractor()
43
+ parser.feed(value)
44
+ text = html.unescape("".join(parser.parts))
45
+ return "\n".join(line.strip() for line in text.splitlines() if line.strip())
46
+
47
+
48
+ def convert_batch(items: list[dict]) -> list[dict]:
49
+ context = []
50
+ for item in items:
51
+ question = item["question"]
52
+ answer = item["answer"]
53
+ context.append({
54
+ "question_id": question["question_id"],
55
+ "title": question["title"],
56
+ "question": plain(question["body"])[:5000],
57
+ "accepted_answer": plain(answer["body"])[:5000],
58
+ })
59
+ payload = {
60
+ "model": MODEL,
61
+ "messages": [
62
+ {
63
+ "role": "system",
64
+ "content": (
65
+ "Convert real Stack Overflow jq questions into executable evaluation tasks. Return only valid JSON "
66
+ "with a tasks array. Include only questions solvable by one jq command reading a single JSON stream "
67
+ "on stdin and writing to stdout. Skip multi-file, filename, shell pipeline, shell variable, module, "
68
+ "environment, additional-input, subprocess, interactive, network, and general discussion questions. "
69
+ "For each suitable question return question_id, request, command, input_text, and validation_input. "
70
+ "The request must be a natural, self-contained English instruction preserving the question's intent. "
71
+ "The command must start with jq, contain exactly one filter and no filename, and use at most one "
72
+ "option from -c, -r, or -s. Do not use other options, env, $ENV, import, include, load, input, or "
73
+ "inputs. Prefer a command supported by the accepted answer, simplified only when needed for stdin "
74
+ "and stdout. Provide two different representative JSON inputs with up to 8 records or lines each "
75
+ "and the same schema. Use JSON Lines only with -s. Do not hardcode answers into the command. Do not "
76
+ "include expected outputs; they will be computed by execution."
77
+ ),
78
+ },
79
+ {"role": "user", "content": "Return {\"tasks\": [...]} or an empty list when unsuitable.\n" + json.dumps(context, ensure_ascii=False)},
80
+ ],
81
+ "response_format": {"type": "json_object"},
82
+ "temperature": 0.2,
83
+ "max_tokens": 6000,
84
+ "reasoning": {"enabled": False},
85
+ }
86
+ request = urllib.request.Request(
87
+ os.environ["OPENROUTER_BASE_URL"].rstrip("/") + "/chat/completions",
88
+ data=json.dumps(payload).encode("utf-8"),
89
+ headers={"Authorization": "Bearer " + os.environ["OPENROUTER_API_KEY"], "Content-Type": "application/json"},
90
+ )
91
+ for attempt in range(5):
92
+ try:
93
+ with urllib.request.urlopen(request, timeout=180) as response:
94
+ data = json.load(response)
95
+ return json.loads(data["choices"][0]["message"]["content"])["tasks"]
96
+ except Exception:
97
+ if attempt == 4:
98
+ raise
99
+ time.sleep(min(30, 2 ** attempt))
100
+ raise AssertionError("unreachable")
101
+
102
+
103
+ def main() -> None:
104
+ parser = argparse.ArgumentParser()
105
+ parser.add_argument("--questions", default=".tmp/jq-questions.json")
106
+ parser.add_argument("--answers", default=".tmp/jq-answers.json")
107
+ parser.add_argument("--output", default="jqweave-so.jsonl")
108
+ parser.add_argument("--raw-output", default=".tmp/jq-converted-raw.json")
109
+ parser.add_argument("--skipped-output", default=".tmp/jq-converted-skipped.json")
110
+ args = parser.parse_args()
111
+ questions = json.load(open(args.questions))["items"]
112
+ answers = json.load(open(args.answers))
113
+ items = []
114
+ for question in questions:
115
+ if "accepted_answer_id" in question:
116
+ items.append({"question": question, "answer": answers[str(question["accepted_answer_id"])]})
117
+ batches = [items[index:index + 4] for index in range(0, len(items), 4)]
118
+ raw = []
119
+ with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
120
+ futures = {executor.submit(convert_batch, batch): batch for batch in batches}
121
+ for future in concurrent.futures.as_completed(futures):
122
+ try:
123
+ raw.extend(future.result())
124
+ except Exception as error:
125
+ print("batch failed", error, flush=True)
126
+ Path(args.raw_output).parent.mkdir(parents=True, exist_ok=True)
127
+ Path(args.raw_output).write_text(json.dumps(raw, indent=2), encoding="utf-8")
128
+
129
+ accepted = []
130
+ skipped = []
131
+ seen = set()
132
+ for item in raw:
133
+ question_id = item.get("question_id")
134
+ if question_id in seen:
135
+ continue
136
+ seen.add(question_id)
137
+ matching = next((entry for entry in items if entry["question"]["question_id"] == question_id), None)
138
+ if matching is None:
139
+ continue
140
+ try:
141
+ request_text = item["request"].strip()
142
+ command = item["command"].strip()
143
+ input_text = item["input_text"]
144
+ validation_input = item["validation_input"]
145
+ if not request_text or input_text == validation_input:
146
+ raise ValueError("Missing request or identical inputs")
147
+ expected = run_jq(command, input_text)
148
+ validation_expected = run_jq(command, validation_input)
149
+ if not expected.strip() or not validation_expected.strip():
150
+ raise ValueError("Empty output")
151
+ if expected == input_text and validation_expected == validation_input:
152
+ raise ValueError("No transformation")
153
+ question = matching["question"]
154
+ answer = matching["answer"]
155
+ accepted.append({
156
+ "id": f"so-{question_id}", "request": request_text, "command": command,
157
+ "input_text": input_text, "expected_output": expected,
158
+ "validation_input": validation_input, "validation_output": validation_expected,
159
+ "family": "real-stackoverflow", "difficulty": 3, "split": "test",
160
+ "source": "stackoverflow-accepted-answer", "license": "CC-BY-SA-4.0",
161
+ "question_url": question["link"], "question_title": question["title"],
162
+ "question_owner": question["owner"].get("display_name"),
163
+ "answer_owner": answer["owner"].get("display_name"),
164
+ "answer_id": answer["answer_id"], "question_score": question["score"],
165
+ })
166
+ except Exception as error:
167
+ skipped.append({"question_id": question_id, "reason": str(error)[:300]})
168
+ accepted.sort(key=lambda row: row["id"])
169
+ with open(args.output, "w", encoding="utf-8") as handle:
170
+ for row in accepted:
171
+ handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
172
+ Path(args.skipped_output).write_text(json.dumps(skipped, indent=2), encoding="utf-8")
173
+ print(f"accepted {len(accepted)} tasks; skipped {len(skipped)} invalid tasks from {len(raw)} candidates")
174
+
175
+
176
+ if __name__ == "__main__":
177
+ main()
data/test.jsonl ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id":"so-18592173","request":"From a JSON object where values are objects containing 'name' and 'location', select only those objects where 'location' is 'Stockholm' and output their 'name' values.","command":"jq -r '.[] | select(.location == \"Stockholm\") | .name'","input_text":"{\"FOO\": {\"name\": \"Donald\", \"location\": \"Stockholm\"}, \"BAR\": {\"name\": \"Walt\", \"location\": \"Stockholm\"}, \"BAZ\": {\"name\": \"Jack\", \"location\": \"Whereever\"}}","expected_output":"Donald\nWalt\n","validation_input":"{\"A\": {\"name\": \"Alice\", \"location\": \"Stockholm\"}, \"B\": {\"name\": \"Bob\", \"location\": \"London\"}}","validation_output":"Alice\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq","question_title":"Select objects based on value of variable in object using jq","question_owner":"Daniel","answer_owner":"Daniel","answer_id":18608100,"question_score":557,"reviewed":true}
2
+ {"id":"so-1955505","request":"Extract the value of the 'text' field from a JSON object.","command":"jq -r '.text'","input_text":"{\"text\": \"My status\", \"favorited\": false}","expected_output":"My status\n","validation_input":"{\"text\": \"Another update\", \"favorited\": true}","validation_output":"Another update\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools","question_title":"Parsing JSON with Unix tools","question_owner":"auser","answer_owner":"Brian Campbell","answer_id":1955555,"question_score":1322,"reviewed":true}
3
+ {"id":"so-19573517","request":"Select and output only the objects from the input stream where the 'geo' field is not null.","command":"jq 'select(.geo != null)'","input_text":"{\"geo\": {\"lat\": 1.0}}\n{\"geo\": null}\n{\"geo\": {\"lat\": 2.0}}","expected_output":"{\n \"geo\": {\n \"lat\": 1\n }\n}\n{\n \"geo\": {\n \"lat\": 2\n }\n}\n","validation_input":"{\"geo\": null}\n{\"geo\": {\"lng\": 5.0}}\n{\"geo\": null}","validation_output":"{\n \"geo\": {\n \"lng\": 5\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/19573517/jq-conditional-output","question_title":"jq Conditional output","question_owner":"clwen","answer_owner":"max taldykin","answer_id":20489951,"question_score":120,"reviewed":true}
4
+ {"id":"so-20181467","request":"Convert a JSON object with dynamic keys into CSV format, where each line contains the key and value quoted and separated by a comma.","command":"jq -r 'to_entries[] | [.key, .value] | @csv'","input_text":"{\"123\":\"abc\",\"231\":\"dbh\",\"452\":\"xyz\"}","expected_output":"\"123\",\"abc\"\n\"231\",\"dbh\"\n\"452\",\"xyz\"\n","validation_input":"{\"a\":\"1\",\"b\":\"2\"}","validation_output":"\"a\",\"1\"\n\"b\",\"2\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20181467/how-to-map-an-object-to-arrays-so-it-can-be-converted-to-csv","question_title":"How to map an object to arrays so it can be converted to csv?","question_owner":"lsl","answer_owner":"Jeff Mercado","answer_id":24254365,"question_score":54,"reviewed":true}
5
+ {"id":"so-21334348","request":"Count the number of items in the top-level JSON array.","command":"jq length","input_text":"[\n {\n \"cid\": 49,\n \"pyn\": \"yi4\",\n \"hans\": \"亿\",\n \"hant\": \"億\",\n \"tid\": 68,\n \"l10n\": \"cent million\",\n \"pid\": 1,\n \"pos\": \"num\",\n \"pos_txt\": \"\"\n },\n {\n \"cid\": 50,\n \"pyn\": \"yi4\",\n \"hans\": \"亿\",\n \"hant\": \"億\",\n \"tid\": 69,\n \"l10n\": \"100 millions\",\n \"pid\": 1,\n \"pos\": \"num\",\n \"pos_txt\": \"\"\n }\n]","expected_output":"2\n","validation_input":"[\n {\n \"id\": 1\n },\n {\n \"id\": 2\n },\n {\n \"id\": 3\n }\n]","validation_output":"3\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/21334348/how-to-count-items-in-json-object-using-command-line","question_title":"How to count items in JSON object using command line?","question_owner":"&#201;douard Lopez","answer_owner":"Ken","answer_id":21355442,"question_score":476,"reviewed":true}
6
+ {"id":"so-23118341","request":"Extract the keys from the JSON object as a sorted array of strings.","command":"jq keys","input_text":"{\n \"email\": \"madireddy@test.com\",\n \"versionID\": \"2323\",\n \"context\": \"test\",\n \"date\": \"02-03-2014-13:41\",\n \"versionName\": \"application\"\n}","expected_output":"[\n \"context\",\n \"date\",\n \"email\",\n \"versionID\",\n \"versionName\"\n]\n","validation_input":"{\n \"Created-By\": \"Apache Maven\",\n \"Build-Number\": \"\",\n \"Archiver-Version\": \"Plexus Archiver\"\n}","validation_output":"[\n \"Archiver-Version\",\n \"Build-Number\",\n \"Created-By\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/23118341/how-to-get-key-names-from-json-using-jq","question_title":"How to get key names from JSON using jq","question_owner":"Ezhilan Mahalingam","answer_owner":"anubhava","answer_id":23118607,"question_score":314,"reviewed":true}
7
+ {"id":"so-24698188","request":"Given a JSON array of objects, flatten each object by removing the 'fields' key and promoting its values (taking the first element if they are arrays) to the top level, while preserving other top-level keys.","command":"jq 'map(with_entries(select(.key != \"fields\")) + (.fields | with_entries(.value = .value[0])))'","input_text":"[\n {\n \"index\": \"index1\",\n \"type\": \"type1\",\n \"id\": \"id1\",\n \"fields\": {\n \"deviceOs\": [\"Android\"],\n \"deviceID\": [\"deviceID1\"],\n \"country\": [\"DE\"]\n }\n },\n {\n \"index\": \"index2\",\n \"type\": \"type2\",\n \"id\": \"id2\",\n \"fields\": {\n \"deviceOs\": [\"iOS\"],\n \"deviceID\": [\"deviceID2\"],\n \"country\": [\"US\"]\n }\n }\n]","expected_output":"[\n {\n \"index\": \"index1\",\n \"type\": \"type1\",\n \"id\": \"id1\",\n \"deviceOs\": \"Android\",\n \"deviceID\": \"deviceID1\",\n \"country\": \"DE\"\n },\n {\n \"index\": \"index2\",\n \"type\": \"type2\",\n \"id\": \"id2\",\n \"deviceOs\": \"iOS\",\n \"deviceID\": \"deviceID2\",\n \"country\": \"US\"\n }\n]\n","validation_input":"[\n {\n \"index\": \"idx1\",\n \"val\": \"v1\",\n \"fields\": {\n \"a\": [\"x\"],\n \"b\": [\"y\"]\n }\n }\n]","validation_output":"[\n {\n \"index\": \"idx1\",\n \"val\": \"v1\",\n \"a\": \"x\",\n \"b\": \"y\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24698188/flatten-a-json-document-using-jq","question_title":"Flatten a JSON document using jq","question_owner":"Dror","answer_owner":"Jeff Mercado","answer_id":24710337,"question_score":39,"reviewed":true}
8
+ {"id":"so-25378013","request":"Convert a JSON object into a list of strings where each string is formatted as \"key=value\".","command":"jq -r 'to_entries|map(\"\\(.key)=\\(.value|tostring)\")|.[]'","input_text":"{\n \"var\": 1,\n \"foo\": \"bar\",\n \"x\": \"test\"\n}","expected_output":"var=1\nfoo=bar\nx=test\n","validation_input":"{\n \"name\": \"Alice\",\n \"age\": 30,\n \"active\": true\n}","validation_output":"name=Alice\nage=30\nactive=true\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25378013/how-to-convert-a-json-object-to-key-value-format-in-jq","question_title":"How to convert a JSON object to key=value format in jq?","question_owner":"gianebao","answer_owner":"aioobe","answer_id":25378171,"question_score":75,"reviewed":true}
9
+ {"id":"so-26701538","request":"From a JSON array of objects each having an 'Id' string and a 'Names' array of strings, filter out any object where any name in 'Names' contains the substring 'data', and output the 'Id' of the remaining objects.","command":"jq -r '.[] | select(.Names | all(contains(\"data\") | not)) | .Id'","input_text":"[{\"Id\": \"abc\", \"Names\": [\"condescending_jones\"]}, {\"Id\": \"def\", \"Names\": [\"foo_data\"]}]","expected_output":"abc\n","validation_input":"[{\"Id\": \"123\", \"Names\": [\"jovial_wozniak\"]}, {\"Id\": \"456\", \"Names\": [\"bar_data\"]}, {\"Id\": \"mix\", \"Names\": [\"foo_data\", \"safe\"]}]","validation_output":"123\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/26701538/jq-how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array","question_title":"jq: how to filter an array of objects based on values in an inner array?","question_owner":"Abe Voelker","answer_owner":"Iain Samuel McLean Elder","answer_id":26701851,"question_score":518,"reviewed":true}
10
+ {"id":"so-27562424","request":"For each object in the input array, create a new object containing the top-level id and the value of info-spec from the nested stuff object.","command":"jq '[.[] | {id, \"info-spec\": .stuff[\"info-spec\"]}]'","input_text":"[{\"id\": 12345678, \"stuff\": {\"book\": \"shelf\", \"hook\": \"line\", \"took\": \"off\", \"info-spec\": 12}, \"votes\": 23}, {\"id\": 12345679, \"stuff\": {\"book\": \"maker\", \"hook\": \"sinker\", \"took\": \"pisin\", \"info-spec\": 23}, \"votes\": 1}]","expected_output":"[\n {\n \"id\": 12345678,\n \"info-spec\": 12\n },\n {\n \"id\": 12345679,\n \"info-spec\": 23\n }\n]\n","validation_input":"[{\"id\": 999, \"stuff\": {\"info-spec\": 100, \"other\": \"val\"}}, {\"id\": 888, \"stuff\": {\"info-spec\": 200, \"other\": \"val2\"}}]","validation_output":"[\n {\n \"id\": 999,\n \"info-spec\": 100\n },\n {\n \"id\": 888,\n \"info-spec\": 200\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/27562424/jq-nested-object-extract-top-level-id-and-lift-a-value-from-internal-object","question_title":"jq: nested object, extract top-level id and lift a value from internal object","question_owner":"tripleee","answer_owner":"tripleee","answer_id":27562901,"question_score":42,"reviewed":true}
11
+ {"id":"so-28484534","request":"Read a stream of JSON objects and output a single object where each key's value is the sum of that key's values across all input objects.","command":"jq -s '[.[] | to_entries] | add | group_by(.key) | map({key: .[0].key, value: map(.value) | add}) | from_entries'","input_text":"{ \"a\": 10, \"b\": 11 }\n{ \"a\": 20, \"b\": 21 }","expected_output":"{\n \"a\": 30,\n \"b\": 32\n}\n","validation_input":"{ \"x\": 5, \"y\": 10 }\n{ \"x\": 15, \"y\": 20 }\n{ \"x\": 0, \"y\": 5 }","validation_output":"{\n \"x\": 20,\n \"y\": 35\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28484534/how-do-i-sum-the-values-in-an-array-of-maps-in-jq","question_title":"How do I sum the values in an array of maps in jq?","question_owner":"Alan Burlison","answer_owner":"Jeff Mercado","answer_id":28485485,"question_score":46,"reviewed":true}
12
+ {"id":"so-29404575","request":"Convert a stream of JSON objects into a single JSON array containing all the objects.","command":"jq -s '.'","input_text":"{\"a\":1}\n{\"b\":2}","expected_output":"[\n {\n \"a\": 1\n },\n {\n \"b\": 2\n }\n]\n","validation_input":"{\"x\":\"foo\"}\n{\"y\":\"bar\"}\n{\"z\":123}","validation_output":"[\n {\n \"x\": \"foo\"\n },\n {\n \"y\": \"bar\"\n },\n {\n \"z\": 123\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29404575/how-to-convert-a-json-object-stream-into-an-array-with-jq","question_title":"How to convert a JSON object stream into an array with jq","question_owner":"Qiang Li","answer_owner":"Jeff Mercado","answer_id":29404613,"question_score":46,"reviewed":true}
13
+ {"id":"so-29949184","request":"Filter a JSON object to keep only items with id \"123\" in the \"requests\" array if it exists and is non-empty, otherwise output nothing.","command":"jq 'if (.requests | length) != 0 then .requests |= map(select(.id == \"123\")) else empty end'","input_text":"{\"requests\":[{\"id\":\"123\"},{\"id\":\"456\"}]}","expected_output":"{\n \"requests\": [\n {\n \"id\": \"123\"\n }\n ]\n}\n","validation_input":"{\"requests\":[{\"id\":\"789\"}]}","validation_output":"{\n \"requests\": []\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29949184/json-jq-if-without-else","question_title":"JSON JQ if without else","question_owner":"user1578872","answer_owner":"peak","answer_id":29962258,"question_score":53,"reviewed":true}
14
+ {"id":"so-31034746","request":"Set the value of the key \"local\" inside the \"shipping\" object to false, preserving the rest of the JSON structure.","command":"jq '.shipping.local = false'","input_text":"{\"shipping\": {\"local\": true, \"us\": true, \"us_rate\": {\"amount\": \"0.00\", \"currency\": \"USD\", \"symbol\": \"$\"}}}","expected_output":"{\n \"shipping\": {\n \"local\": false,\n \"us\": true,\n \"us_rate\": {\n \"amount\": \"0.00\",\n \"currency\": \"USD\",\n \"symbol\": \"$\"\n }\n }\n}\n","validation_input":"{\"shipping\": {\"local\": true, \"international\": false}, \"other\": \"data\"}","validation_output":"{\n \"shipping\": {\n \"local\": false,\n \"international\": false\n },\n \"other\": \"data\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31034746/how-do-i-update-a-single-value-in-a-json-document-using-jq","question_title":"How do I update a single value in a json document using jq?","question_owner":"STW","answer_owner":"Jeff Mercado","answer_id":31037640,"question_score":231,"reviewed":true}
15
+ {"id":"so-33247228","request":"Pretty-print the input JSON using jq's default formatting.","command":"jq '.'","input_text":"{\"name\": \"octocat\", \"id\": 1}","expected_output":"{\n \"name\": \"octocat\",\n \"id\": 1\n}\n","validation_input":"{\"key\": \"value\", \"nested\": {\"a\": 1}}","validation_output":"{\n \"key\": \"value\",\n \"nested\": {\n \"a\": 1\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33247228/how-to-use-jq-in-a-shell-pipeline","question_title":"How to use `jq` in a shell pipeline?","question_owner":"mgalgs","answer_owner":"chepner","answer_id":33247259,"question_score":244,"reviewed":true}
16
+ {"id":"so-33895076","request":"Given a JSON array of objects containing 'timestamp', 'group', and 'uid' fields, output each object's 'group' and 'uid' values joined by a comma on separate lines.","command":"jq -r '.[]|[.group,.uid]|join(\",\")'","input_text":"[\n {\n \"timestamp\": 1448369447295,\n \"group\": \"employees\",\n \"uid\": \"elgalu\"\n },\n {\n \"timestamp\": 1448369447296,\n \"group\": \"employees\",\n \"uid\": \"mike\"\n },\n {\n \"timestamp\": 1448369786667,\n \"group\": \"services\",\n \"uid\": \"pacts\"\n }\n]","expected_output":"employees,elgalu\nemployees,mike\nservices,pacts\n","validation_input":"[\n {\n \"timestamp\": 100,\n \"group\": \"admin\",\n \"uid\": \"root\"\n },\n {\n \"timestamp\": 200,\n \"group\": \"users\",\n \"uid\": \"guest\"\n }\n]","validation_output":"admin,root\nusers,guest\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33895076/exclude-column-from-jq-json-output","question_title":"Exclude column from jq json output","question_owner":"Leo Gallucci","answer_owner":"hek2mgl","answer_id":33895231,"question_score":87,"reviewed":true}
17
+ {"id":"so-33947584","request":"Extract start_id and end_id from each JSON object and print them on the same line separated by a space, without surrounding double quotes.","command":"jq -r '\"\\(.start_id) \\(.end_id)\"'","input_text":"{\"start_id\":1,\"end_id\":50}\n{\"start_id\":50,\"end_id\":99}\n{\"start_id\":99,\"end_id\":12}","expected_output":"1 50\n50 99\n99 12\n","validation_input":"{\"start_id\":10,\"end_id\":20}\n{\"start_id\":20,\"end_id\":30}","validation_output":"10 20\n20 30\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33947584/concat-numbers-from-json-without-doublequotes-using-jq","question_title":"Concat numbers from JSON without doublequotes using jq","question_owner":"Synesso","answer_owner":"xjedam","answer_id":33952189,"question_score":39,"reviewed":true}
18
+ {"id":"so-34226370","request":"Given a JSON object where keys are hostnames and values are objects containing an 'ip' field, output each hostname and its corresponding IP address as a comma-separated string on separate lines.","command":"jq -r 'to_entries[] | \"\\(.key), \\(.value.ip)\"'","input_text":"{\n \"host1\": { \"ip\": \"10.1.2.3\" },\n \"host2\": { \"ip\": \"10.1.2.2\" },\n \"host3\": { \"ip\": \"10.1.18.1\" }\n}","expected_output":"host1, 10.1.2.3\nhost2, 10.1.2.2\nhost3, 10.1.18.1\n","validation_input":"{\n \"serverA\": { \"ip\": \"192.168.1.1\" },\n \"serverB\": { \"ip\": \"192.168.1.2\" }\n}","validation_output":"serverA, 192.168.1.1\nserverB, 192.168.1.2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34226370/jq-print-key-and-value-for-each-entry-in-an-object","question_title":"jq: print key and value for each entry in an object","question_owner":"Jeff Tang","answer_owner":"peak","answer_id":34227629,"question_score":164,"reviewed":true}
19
+ {"id":"so-34340549","request":"Parse the JSON string contained in the \"text\" field of the \"response\" object and extract the \"title\" field from the parsed JSON.","command":"jq '.response.text | fromjson | .title'","input_text":"{\n \"requestType\": \"POST\",\n \"response\": {\n \"size\": 78,\n \"text\": \"{\\\"recordID\\\":123, \\\"title\\\":\\\"Hello World\\\", \\\"content\\\":\\\"Lorem ipsum...\\\"}\"\n }\n}","expected_output":"\"Hello World\"\n","validation_input":"{\n \"requestType\": \"GET\",\n \"response\": {\n \"size\": 50,\n \"text\": \"{\\\"id\\\":456, \\\"title\\\":\\\"Goodbye World\\\", \\\"data\\\":null}\"\n }\n}","validation_output":"\"Goodbye World\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34340549/convert-string-to-json-in-jq","question_title":"Convert string to json in jq","question_owner":"RJ-Adam","answer_owner":"Jeff Mercado","answer_id":34340787,"question_score":100,"reviewed":true}
20
+ {"id":"so-34543829","request":"Extract the 'def' value from the 'aux' array within each object of the top-level array.","command":"jq -r '.[].aux[].def'","input_text":"[{\"id\": 123, \"name\": \"John\", \"aux\": [{\"abc\": \"random\", \"def\": \"I want this\"}], \"blah\": 23.11}]","expected_output":"I want this\n","validation_input":"[{\"id\": 456, \"name\": \"Jane\", \"aux\": [{\"abc\": \"x\", \"def\": \"Target Value\"}], \"blah\": 10.0}]","validation_output":"Target Value\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34543829/jq-cannot-index-array-with-string","question_title":"jq: Cannot index array with string","question_owner":"Xu Wang","answer_owner":"hek2mgl","answer_id":34544406,"question_score":115,"reviewed":true}
21
+ {"id":"so-35086391","request":"Given a JSON object where values are objects with a single key, output all the inner keys as a stream of strings.","command":"jq '.[] | keys[]'","input_text":"{\n \"keyword1\": {\n \"identifier1\": 16\n },\n \"keyword2\": {\n \"identifier2\": 16\n }\n}","expected_output":"\"identifier1\"\n\"identifier2\"\n","validation_input":"{\n \"groupA\": {\n \"nameA\": 1\n },\n \"groupB\": {\n \"nameB\": 2\n }\n}","validation_output":"\"nameA\"\n\"nameB\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35086391/jq-how-to-iterate-through-keys-of-different-names","question_title":"jq - How to iterate through keys of different names","question_owner":"Adam vonNieda","answer_owner":"peak","answer_id":35091473,"question_score":40,"reviewed":true}
22
+ {"id":"so-35154684","request":"Parse the JSON string contained in the field \"c\" and extract the value of its \"id\" field.","command":"jq '.c | fromjson | .id'","input_text":"{\"a\": 1, \"b\": 2, \"c\": \"{\\\"id\\\":\\\"9ee\\\",\\\"parent\\\":\\\"abc\\\"}\"}","expected_output":"\"9ee\"\n","validation_input":"{\"x\": 10, \"c\": \"{\\\"id\\\":\\\"xyz123\\\",\\\"type\\\":\\\"user\\\"}\"}","validation_output":"\"xyz123\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35154684/how-to-parse-a-json-string-with-jq-or-other-alternatives","question_title":"how to parse a JSON String with jq (or other alternatives)?","question_owner":"Colin Grogan","answer_owner":"jwodder","answer_id":35155249,"question_score":217,"reviewed":true}
23
+ {"id":"so-35677309","request":"Extract the \"AssetId\" value from each object in a JSON array and output them as raw strings.","command":"jq -r '.[] | .AssetId'","input_text":"[\n {\n \"AssetId\": 14462955,\n \"Name\": \"Cultural Item\"\n },\n {\n \"AssetId\": 114385498,\n \"Name\": \"Redspybot\"\n },\n {\n \"AssetId\": 29715011,\n \"Name\": \"American Cowboy\"\n },\n {\n \"AssetId\": 98253651,\n \"Name\": \"Mahem\"\n }\n]","expected_output":"14462955\n114385498\n29715011\n98253651\n","validation_input":"[\n {\n \"AssetId\": 100,\n \"Name\": \"Item A\"\n },\n {\n \"AssetId\": 200,\n \"Name\": \"Item B\"\n }\n]","validation_output":"100\n200\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35677309/output-specific-key-value-in-object-for-each-element-in-array-with-jq-for-json","question_title":"Output specific key value in object for each element in array with jq for JSON","question_owner":"Zimbabwe Elephant","answer_owner":"peak","answer_id":35677443,"question_score":98,"reviewed":true}
24
+ {"id":"so-36227245","request":"Remove the keys \"Country\", \"number\", and \"Language\" from each object in a JSON array.","command":"jq 'map(del(.Country, .number, .Language))'","input_text":"[\n {\n \"label\": \"US : USA : English\",\n \"Country\": \"USA\",\n \"region\": \"US\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"USD\",\n \"number\": \"USD\"\n },\n {\n \"label\": \"AU : Australia : English\",\n \"Country\": \"Australia\",\n \"region\": \"AU\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"AUD\",\n \"number\": \"AUD\"\n }\n]","expected_output":"[\n {\n \"label\": \"US : USA : English\",\n \"region\": \"US\",\n \"locale\": \"en\",\n \"currency\": \"USD\"\n },\n {\n \"label\": \"AU : Australia : English\",\n \"region\": \"AU\",\n \"locale\": \"en\",\n \"currency\": \"AUD\"\n }\n]\n","validation_input":"[\n {\n \"label\": \"CA : Canada : English\",\n \"Country\": \"Canada\",\n \"region\": \"CA\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"CAD\",\n \"number\": \"CAD\"\n },\n {\n \"label\": \"GB : UK : English\",\n \"Country\": \"UK\",\n \"region\": \"GB\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"GBP\",\n \"number\": \"GBP\"\n }\n]","validation_output":"[\n {\n \"label\": \"CA : Canada : English\",\n \"region\": \"CA\",\n \"locale\": \"en\",\n \"currency\": \"CAD\"\n },\n {\n \"label\": \"GB : UK : English\",\n \"region\": \"GB\",\n \"locale\": \"en\",\n \"currency\": \"GBP\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/36227245/deleting-multiple-keys-at-once-with-jq","question_title":"Deleting multiple keys at once with jq","question_owner":"antun","answer_owner":"user3899165","answer_id":36228054,"question_score":79,"reviewed":true}
25
+ {"id":"so-37344329","request":"Extract the value of the key \"component-status\" from a JSON object.","command":"jq '.\"component-status\"'","input_text":"{\n \"status\": \"ok\",\n \"hostname\": \"0b0b495a46db\",\n \"component-status\": [\n {\n \"status-code\": 200,\n \"component\": \"Service1\",\n \"status\": \"OK\"\n },\n {\n \"status-code\": 200,\n \"component\": \"Service2\",\n \"status\": \"OK\"\n }\n ]\n}","expected_output":"[\n {\n \"status-code\": 200,\n \"component\": \"Service1\",\n \"status\": \"OK\"\n },\n {\n \"status-code\": 200,\n \"component\": \"Service2\",\n \"status\": \"OK\"\n }\n]\n","validation_input":"{\n \"status\": \"error\",\n \"hostname\": \"test-host\",\n \"component-status\": [\n {\n \"status-code\": 500,\n \"component\": \"DB\",\n \"status\": \"FAIL\"\n }\n ]\n}","validation_output":"[\n {\n \"status-code\": 500,\n \"component\": \"DB\",\n \"status\": \"FAIL\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37344329/jq-not-working-on-tag-name-with-dashes-and-numbers","question_title":"jq not working on tag name with dashes and numbers","question_owner":"paul","answer_owner":"fedorqui","answer_id":37344498,"question_score":102,"reviewed":true}
26
+ {"id":"so-37563691","request":"Extract the md5 value from the object in the files array where the fileName is \"FOO\".","command":"jq -r '.files[] | select(.fileName==\"FOO\") | .md5'","input_text":"{\"files\": [{\"fileName\": \"FOO\", \"md5\": \"blablabla\"}, {\"fileName\": \"BAR\", \"md5\": \"alaldlafj\"}]}","expected_output":"blablabla\n","validation_input":"{\"files\": [{\"fileName\": \"TEST\", \"md5\": \"abc123\"}, {\"fileName\": \"FOO\", \"md5\": \"xyz789\"}, {\"fileName\": \"BAZ\", \"md5\": \"def456\"}]}","validation_output":"xyz789\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37563691/jq-select-value-from-array","question_title":"jq select value from array","question_owner":"Marvin Effing","answer_owner":"Marvin Effing","answer_id":37567004,"question_score":82,"reviewed":true}
27
+ {"id":"so-37577683","request":"Extract the value of the 'hostName' field from all top-level values in a JSON object, regardless of the top-level keys.","command":"jq -r '.[].hostName'","input_text":"{\"key1\": {\"hostName\": \"server1\", \"state\": \"READY\"}, \"key2\": {\"hostName\": \"server2\", \"state\": \"STOPPED\"}}","expected_output":"server1\nserver2\n","validation_input":"{\"abc-123\": {\"hostName\": \"node-alpha\", \"ip\": \"10.0.0.1\"}, \"xyz-789\": {\"hostName\": \"node-beta\", \"ip\": \"10.0.0.2\"}}","validation_output":"node-alpha\nnode-beta\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37577683/how-to-use-jq-to-obtain-the-keys","question_title":"How to use `jq` to obtain the keys","question_owner":"sudhishkr","answer_owner":"Andreas Louv","answer_id":37577805,"question_score":47,"reviewed":true}
28
+ {"id":"so-37710718","request":"Create a new JSON object containing a single field named 'channel' whose value is the concatenation of the input's 'profile_type', a dot, and the input's 'channel' value.","command":"jq '{channel: (.profile_type + \".\" + .channel)}'","input_text":"{\"channel\": \"youtube\", \"profile_type\": \"video\", \"member_key\": \"hello\"}","expected_output":"{\n \"channel\": \"video.youtube\"\n}\n","validation_input":"{\"channel\": \"twitch\", \"profile_type\": \"stream\", \"member_key\": \"world\"}","validation_output":"{\n \"channel\": \"stream.twitch\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37710718/concat-2-fields-in-json-using-jq","question_title":"Concat 2 fields in JSON using jq","question_owner":"darthsidious","answer_owner":"Anthony Battaglia","answer_id":37710802,"question_score":177,"reviewed":true}
29
+ {"id":"so-38061346","request":"Read a stream of multiple JSON objects from stdin and combine them into a single JSON array.","command":"jq -s '.'","input_text":"{\"name\": \"John\", \"email\": \"john@company.com\"}\n{\"name\": \"Brad\", \"email\": \"brad@company.com\"}","expected_output":"[\n {\n \"name\": \"John\",\n \"email\": \"john@company.com\"\n },\n {\n \"name\": \"Brad\",\n \"email\": \"brad@company.com\"\n }\n]\n","validation_input":"{\"id\": 1, \"status\": \"active\"}\n{\"id\": 2, \"status\": \"inactive\"}\n{\"id\": 3, \"status\": \"pending\"}","validation_output":"[\n {\n \"id\": 1,\n \"status\": \"active\"\n },\n {\n \"id\": 2,\n \"status\": \"inactive\"\n },\n {\n \"id\": 3,\n \"status\": \"pending\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38061346/jq-output-array-of-json-objects","question_title":"jq: output array of json objects","question_owner":"Mauricio Trajano","answer_owner":"chepner","answer_id":38061430,"question_score":134,"reviewed":true}
30
+ {"id":"so-38121740","request":"Filter the 'theList' array to include only objects where the 'id' is either 2 or 4.","command":"jq '.theList[] | select(.id == 2 or .id == 4)'","input_text":"{\"theList\": [{\"id\": 1, \"name\": \"Horst\"}, {\"id\": 2, \"name\": \"Fritz\"}, {\"id\": 3, \"name\": \"Walter\"}, {\"id\": 4, \"name\": \"Gerhart\"}, {\"id\": 5, \"name\": \"Harmut\"}]}","expected_output":"{\n \"id\": 2,\n \"name\": \"Fritz\"\n}\n{\n \"id\": 4,\n \"name\": \"Gerhart\"\n}\n","validation_input":"{\"theList\": [{\"id\": 10, \"name\": \"A\"}, {\"id\": 2, \"name\": \"B\"}, {\"id\": 4, \"name\": \"C\"}, {\"id\": 5, \"name\": \"D\"}]}","validation_output":"{\n \"id\": 2,\n \"name\": \"B\"\n}\n{\n \"id\": 4,\n \"name\": \"C\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38121740/how-to-filter-array-of-objects-by-element-property-values-using-jq","question_title":"How to filter array of objects by element property values using jq?","question_owner":"k0pernikus","answer_owner":"Andr&#233; Senra","answer_id":38122029,"question_score":120,"reviewed":true}
31
+ {"id":"so-38500363","request":"Select all objects from the input array where the key 'a' equals 'x', collect them into an array, and return the first element of that resulting array.","command":"jq '[.[] | select(.a == \"x\")][0]'","input_text":"[{\"a\": \"x\", \"b\": true}, {\"a\": \"x\", \"b\": false}, {\"a\": \"XML\", \"b\": false}]","expected_output":"{\n \"a\": \"x\",\n \"b\": true\n}\n","validation_input":"[{\"a\": \"y\", \"b\": true}, {\"a\": \"x\", \"b\": 123}, {\"a\": \"x\", \"b\": 456}]","validation_output":"{\n \"a\": \"x\",\n \"b\": 123\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38500363/get-the-first-or-nth-element-in-a-jq-json-parsing","question_title":"get the first (or n&#39;th) element in a jq json parsing","question_owner":"Demian Glait","answer_owner":"hek2mgl","answer_id":38500610,"question_score":128,"reviewed":true}
32
+ {"id":"so-38689645","request":"Select the parent object from a JSON structure where a nested field \"details.name\" equals \"James Brown\".","command":"jq 'select(.details.name == \"James Brown\")'","input_text":"{\n \"id\": 1,\n \"details\": {\n \"username\": \"jamesbrown\",\n \"name\": \"James Brown\"\n }\n}","expected_output":"{\n \"id\": 1,\n \"details\": {\n \"username\": \"jamesbrown\",\n \"name\": \"James Brown\"\n }\n}\n","validation_input":"{\n \"id\": 2,\n \"details\": {\n \"username\": \"janedoe\",\n \"name\": \"Jane Doe\"\n }\n}\n{\n \"id\": 3,\n \"details\": {\n \"username\": \"jamesbrown2\",\n \"name\": \"James Brown\"\n }\n}","validation_output":"{\n \"id\": 3,\n \"details\": {\n \"username\": \"jamesbrown2\",\n \"name\": \"James Brown\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38689645/how-do-i-print-a-parent-value-of-an-object-when-i-am-already-deep-into-the-objec","question_title":"How do I print a parent value of an object when I am already deep into the object&#39;s children?","question_owner":"x3nr0s","answer_owner":"user3899165","answer_id":38693695,"question_score":75,"reviewed":true}
33
+ {"id":"so-39228500","request":"Extract all 'name' values from the array located at '.example.\"sub-example\"' in the input JSON object.","command":"jq '.example.\"sub-example\" | .[] | .name'","input_text":"{\n \"example\": {\n \"sub-example\": [\n {\n \"name\": \"123-345\",\n \"tag\": 100\n },\n {\n \"name\": \"234-456\",\n \"tag\": 100\n },\n {\n \"name\": \"4a7-a07a5\",\n \"tag\": 100\n }\n ]\n }\n}","expected_output":"\"123-345\"\n\"234-456\"\n\"4a7-a07a5\"\n","validation_input":"{\n \"example\": {\n \"sub-example\": [\n {\n \"name\": \"alpha\",\n \"tag\": 200\n },\n {\n \"name\": \"beta\",\n \"tag\": 200\n }\n ]\n }\n}","validation_output":"\"alpha\"\n\"beta\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39228500/extract-a-specific-field-from-json-output-using-jq","question_title":"Extract a specific field from JSON output using jq","question_owner":"rmb","answer_owner":"aaaaaa123456789","answer_id":39228718,"question_score":160,"reviewed":true}
34
+ {"id":"so-40396445","request":"Extract the key, status name, and assignee email address from each issue in the input JSON object's issues array, and output each result as a compact JSON object on a single line.","command":"jq -c '.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress}'","input_text":"{\"issues\": [{\"key\": \"SEA-739\", \"fields\": {\"status\": {\"name\": \"Open\"}, \"assignee\": null}}, {\"key\": \"SEA-738\", \"fields\": {\"status\": {\"name\": \"Resolved\"}, \"assignee\": {\"emailAddress\": \"user2@mycompany.com\"}}}]}","expected_output":"{\"key\":\"SEA-739\",\"status\":\"Open\",\"assignee\":null}\n{\"key\":\"SEA-738\",\"status\":\"Resolved\",\"assignee\":\"user2@mycompany.com\"}\n","validation_input":"{\"issues\": [{\"key\": \"PROJ-101\", \"fields\": {\"status\": {\"name\": \"In Progress\"}, \"assignee\": {\"emailAddress\": \"dev@example.com\"}}}, {\"key\": \"PROJ-102\", \"fields\": {\"status\": {\"name\": \"Closed\"}, \"assignee\": null}}]}","validation_output":"{\"key\":\"PROJ-101\",\"status\":\"In Progress\",\"assignee\":\"dev@example.com\"}\n{\"key\":\"PROJ-102\",\"status\":\"Closed\",\"assignee\":null}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40396445/get-outputs-from-jq-on-a-single-line","question_title":"Get outputs from jq on a single line","question_owner":"Jitesh Sojitra","answer_owner":"hmedia1","answer_id":40396556,"question_score":187,"reviewed":true}
35
+ {"id":"so-42051601","request":"From a JSON object with a 'data' field, extract the values of keys that case-insensitively match the pattern 'what a burger'.","command":"jq '.data | to_entries | map(select(.key | match(\"what a burger\";\"i\"))) | map(.value)'","input_text":"{\n \"data\": {\n \"what a burger\": [1, 2, 3],\n \"wap\": [66],\n \"the map\": [11, 20],\n \"H. Incandenza\": [1, 1],\n \"What a burger\": [\"a\", \"a\", 3]\n }\n}","expected_output":"[\n [\n 1,\n 2,\n 3\n ],\n [\n \"a\",\n \"a\",\n 3\n ]\n]\n","validation_input":"{\n \"data\": {\n \"WHAT A BURGER\": [10, 20],\n \"other\": [5],\n \"What a Burger\": [\"x\", \"y\"]\n }\n}","validation_output":"[\n [\n 10,\n 20\n ],\n [\n \"x\",\n \"y\"\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42051601/pattern-matching-field-names-with-jq","question_title":"Pattern matching field names with jq","question_owner":"manu","answer_owner":"koalo","answer_id":42051804,"question_score":45,"reviewed":true}
36
+ {"id":"so-42245288","request":"Append a new message object to the messages array within the data object of the input JSON.","command":"jq '.data.messages += [{\"date\": \"2010-01-07T19:55:99.999Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"OKKK\", \"message\": \"metadata loaded into iRODS successfullyyyyy\"}]'","input_text":"{\"report\": \"1.0\", \"data\": {\"date\": \"2010-01-07\", \"messages\": [{\"date\": \"2010-01-07T19:58:42.949Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"OK\", \"message\": \"metadata loaded into iRODS successfully\"}, {\"date\": \"2010-01-07T20:22:46.949Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"NOK\", \"message\": \"metadata duplicated into iRODS\"}]}}","expected_output":"{\n \"report\": \"1.0\",\n \"data\": {\n \"date\": \"2010-01-07\",\n \"messages\": [\n {\n \"date\": \"2010-01-07T19:58:42.949Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OK\",\n \"message\": \"metadata loaded into iRODS successfully\"\n },\n {\n \"date\": \"2010-01-07T20:22:46.949Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"NOK\",\n \"message\": \"metadata duplicated into iRODS\"\n },\n {\n \"date\": \"2010-01-07T19:55:99.999Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OKKK\",\n \"message\": \"metadata loaded into iRODS successfullyyyyy\"\n }\n ]\n }\n}\n","validation_input":"{\"report\": \"2.0\", \"data\": {\"date\": \"2011-01-07\", \"messages\": [{\"date\": \"2011-01-07T10:00:00.000Z\", \"xml\": \"test.xml\", \"status\": \"OK\", \"message\": \"test msg\"}]}}","validation_output":"{\n \"report\": \"2.0\",\n \"data\": {\n \"date\": \"2011-01-07\",\n \"messages\": [\n {\n \"date\": \"2011-01-07T10:00:00.000Z\",\n \"xml\": \"test.xml\",\n \"status\": \"OK\",\n \"message\": \"test msg\"\n },\n {\n \"date\": \"2010-01-07T19:55:99.999Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OKKK\",\n \"message\": \"metadata loaded into iRODS successfullyyyyy\"\n }\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42245288/add-new-element-to-existing-json-array-with-jq","question_title":"Add new element to existing JSON array with jq","question_owner":"Felipe","answer_owner":"Inian","answer_id":42248841,"question_score":133,"reviewed":true}
37
+ {"id":"so-42427725","request":"Convert an array of objects with 'name' and 'value' fields into a single object where each key is the 'name' value and the corresponding value is the original object.","command":"jq 'map({(.name): .}) | add'","input_text":"[\n {\"name\": \"A\", \"value\": \"1\"},\n {\"name\": \"B\", \"value\": \"5\"},\n {\"name\": \"E\", \"value\": \"8\"}\n]","expected_output":"{\n \"A\": {\n \"name\": \"A\",\n \"value\": \"1\"\n },\n \"B\": {\n \"name\": \"B\",\n \"value\": \"5\"\n },\n \"E\": {\n \"name\": \"E\",\n \"value\": \"8\"\n }\n}\n","validation_input":"[\n {\"name\": \"X\", \"value\": \"10\"},\n {\"name\": \"Y\", \"value\": \"20\"}\n]","validation_output":"{\n \"X\": {\n \"name\": \"X\",\n \"value\": \"10\"\n },\n \"Y\": {\n \"name\": \"Y\",\n \"value\": \"20\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42427725/using-jq-convert-array-of-objects-to-object-with-named-keys","question_title":"Using jq, convert array of objects to object with named keys","question_owner":"Mike N","answer_owner":"peak","answer_id":42428341,"question_score":62,"reviewed":true}
38
+ {"id":"so-42746828","request":"Filter objects in a JSON array to keep only those where none of the strings in the \"imageTags\" array contain the text \"latest\".","command":"jq '[.[] | select([.imageTags[] | contains(\"latest\")] | any | not)]'","input_text":"[\n {\n \"imagePushedAt\": 100,\n \"imageTags\": [\"v1\", \"stable\"]\n },\n {\n \"imagePushedAt\": 200,\n \"imageTags\": [\"v2\", \"latest\"]\n },\n {\n \"imagePushedAt\": 300,\n \"imageTags\": [\"v3\"]\n }\n]","expected_output":"[\n {\n \"imagePushedAt\": 100,\n \"imageTags\": [\n \"v1\",\n \"stable\"\n ]\n },\n {\n \"imagePushedAt\": 300,\n \"imageTags\": [\n \"v3\"\n ]\n }\n]\n","validation_input":"[\n {\n \"imagePushedAt\": 400,\n \"imageTags\": [\"release-candidate\"]\n },\n {\n \"imagePushedAt\": 500,\n \"imageTags\": [\"latest-build\"]\n },\n {\n \"imagePushedAt\": 600,\n \"imageTags\": []\n }\n]","validation_output":"[\n {\n \"imagePushedAt\": 400,\n \"imageTags\": [\n \"release-candidate\"\n ]\n },\n {\n \"imagePushedAt\": 600,\n \"imageTags\": []\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42746828/jq-how-to-query-for-array-values-that-dont-contain-text-foo","question_title":"jq: how to query for array values that don&#39;t contain text &quot;foo&quot;?","question_owner":"Gavriel Fishel","answer_owner":"J. Doe","answer_id":42747910,"question_score":92,"reviewed":true}
39
+ {"id":"so-43221453","request":"Group an array of objects by their 'component' field and output separate objects for each component, where the key is the component name and the value is an array of the associated 'ip' addresses.","command":"jq 'group_by(.component)[] | {(.[0].component): [.[] | .ip]}'","input_text":"[\n {\"ip\": \"1.1.1.1\", \"component\": \"name1\"},\n {\"ip\": \"1.1.1.2\", \"component\": \"name1\"},\n {\"ip\": \"1.1.1.3\", \"component\": \"name2\"},\n {\"ip\": \"1.1.1.4\", \"component\": \"name2\"}\n]","expected_output":"{\n \"name1\": [\n \"1.1.1.1\",\n \"1.1.1.2\"\n ]\n}\n{\n \"name2\": [\n \"1.1.1.3\",\n \"1.1.1.4\"\n ]\n}\n","validation_input":"[\n {\"ip\": \"2.2.2.1\", \"component\": \"web\"},\n {\"ip\": \"2.2.2.2\", \"component\": \"db\"},\n {\"ip\": \"2.2.2.3\", \"component\": \"web\"}\n]","validation_output":"{\n \"db\": [\n \"2.2.2.2\"\n ]\n}\n{\n \"web\": [\n \"2.2.2.1\",\n \"2.2.2.3\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43221453/jq-group-and-key-by-property","question_title":"jq: group and key by property","question_owner":"replay","answer_owner":"replay","answer_id":43221520,"question_score":57,"reviewed":true}
40
+ {"id":"so-43291389","request":"Extract the absoluteNumber, airedEpisodeNumber, episodeName, and overview from each object in the data array, joining them with a pipe delimiter per line.","command":"jq -r '.data[] | [.absoluteNumber, .airedEpisodeNumber, .episodeName, .overview] | join(\"|\")'","input_text":"{\"data\": [{\"absoluteNumber\": 51, \"airedEpisodeNumber\": 6, \"episodeName\": \"We Will Rise\", \"overview\": \"Clarke and Roan must work together.\"}]}","expected_output":"51|6|We Will Rise|Clarke and Roan must work together.\n","validation_input":"{\"data\": [{\"absoluteNumber\": 10, \"airedEpisodeNumber\": 1, \"episodeName\": \"Pilot\", \"overview\": \"The beginning.\"}, {\"absoluteNumber\": 11, \"airedEpisodeNumber\": 2, \"episodeName\": \"Second\", \"overview\": \"Continuation.\"}]}","validation_output":"10|1|Pilot|The beginning.\n11|2|Second|Continuation.\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43291389/using-jq-to-assign-multiple-output-variables","question_title":"using jq to assign multiple output variables","question_owner":"user2328273","answer_owner":"Bertrand Martel","answer_id":43293515,"question_score":43,"reviewed":true}
41
+ {"id":"so-43522133","request":"Rename the key \"veg\" to \"fruit2\" and \"worker\" to \"job\" in each object of a JSON array, removing the original keys.","command":"jq '[.[] | .[\"fruit2\"] = .veg | .[\"job\"] = .worker | del(.veg, .worker)]'","input_text":"[{\"fruit\":\"strawberry\",\"veg\":\"apple\",\"worker\":\"gardener\"}]","expected_output":"[\n {\n \"fruit\": \"strawberry\",\n \"fruit2\": \"apple\",\n \"job\": \"gardener\"\n }\n]\n","validation_input":"[{\"fruit\":\"banana\",\"veg\":\"carrot\",\"worker\":\"farmer\"}]","validation_output":"[\n {\n \"fruit\": \"banana\",\n \"fruit2\": \"carrot\",\n \"job\": \"farmer\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43522133/using-jq-how-can-i-replace-the-name-of-a-key-with-something-else","question_title":"Using jq how can I replace the name of a key with something else","question_owner":"user486670","answer_owner":"RomanPerekhrest","answer_id":43522716,"question_score":53,"reviewed":true}
42
+ {"id":"so-44656515","request":"Extract the value of the 'name' field from a JSON object as raw text without surrounding quotes.","command":"jq -r '.name'","input_text":"{\"name\": \"Google\", \"id\": 1}","expected_output":"Google\n","validation_input":"{\"name\": \"Apple\", \"id\": 2}","validation_output":"Apple\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44656515/how-to-remove-double-quotes-in-jq-output-for-parsing-json-files-in-bash","question_title":"How to remove double-quotes in jq output for parsing json files in bash?","question_owner":"Chris F","answer_owner":"Charles Duffy","answer_id":44656583,"question_score":800,"reviewed":true}
43
+ {"id":"so-45165303","request":"For each ticket in the 'tickets' array, output a CSV line where the 'tags' array is joined into a single comma-separated string field.","command":"jq -r '.tickets[] | [.created_at, .id, .via.channel, (.tags | join(\",\"))] | @csv'","input_text":"{\n \"tickets\": [\n {\n \"created_at\": \"2016-02-02T10:00:00Z\",\n \"id\": 99999,\n \"via\": { \"channel\": \"web\" },\n \"tags\": [\"tag1\", \"tag2\", \"tag3\"]\n }\n ]\n}","expected_output":"\"2016-02-02T10:00:00Z\",99999,\"web\",\"tag1,tag2,tag3\"\n","validation_input":"{\n \"tickets\": [\n {\n \"created_at\": \"2023-01-01T00:00:00Z\",\n \"id\": 1,\n \"via\": { \"channel\": \"email\" },\n \"tags\": [\"urgent\", \"bug\"]\n },\n {\n \"created_at\": \"2023-01-02T00:00:00Z\",\n \"id\": 2,\n \"via\": { \"channel\": \"api\" },\n \"tags\": []\n }\n ]\n}","validation_output":"\"2023-01-01T00:00:00Z\",1,\"email\",\"urgent,bug\"\n\"2023-01-02T00:00:00Z\",2,\"api\",\"\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45165303/how-to-combine-an-array-into-a-single-string-value-when-using-csv-output-in-jq","question_title":"How to combine an array into a single string value when using CSV output in jq?","question_owner":"Emre Sevin&#231;","answer_owner":"zwer","answer_id":45165687,"question_score":45,"reviewed":true}
44
+ {"id":"so-45523425","request":"Extract the text field from all objects in the response array, ignoring non-object entries.","command":"jq '.response[] | objects | .text'","input_text":"{\"response\": [1000, {\"id\": 1, \"text\": \"blabla\"}, {\"id\": 2, \"text\": \"hello world\"}]}","expected_output":"\"blabla\"\n\"hello world\"\n","validation_input":"{\"response\": [\"error\", {\"id\": 5, \"text\": \"first post\"}, {\"id\": 6, \"text\": \"second post\"}, null]}","validation_output":"\"first post\"\n\"second post\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45523425/getting-all-the-values-of-an-array-with-jq","question_title":"getting all the values of an array with jq","question_owner":"Miss Alena","answer_owner":"peak","answer_id":45524015,"question_score":80,"reviewed":true}
45
+ {"id":"so-46131727","request":"Extract the 'foo' and 'bar' values from the nested 'fmep' object and print them on the same line separated by a space.","command":"jq -r '.fmep | \"\\(.foo) \\(.bar)\"'","input_text":"{\n \"fmep\": {\n \"foo\": 112,\n \"bar\": 234324,\n \"cat\": 21343423\n }\n}","expected_output":"112 234324\n","validation_input":"{\n \"fmep\": {\n \"foo\": 5,\n \"bar\": 10,\n \"cat\": 15\n }\n}","validation_output":"5 10\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46131727/printing-multiple-values-on-the-same-line","question_title":"Printing multiple values on the same line","question_owner":"Mickster","answer_owner":"jq170727","answer_id":46131963,"question_score":58,"reviewed":true}
46
+ {"id":"so-47023795","request":"Remove the top-level 'pages' key and its value from the JSON object, keeping all other keys intact.","command":"jq 'del(.pages)'","input_text":"{\n \"pages\": {\n \"elems\": { \"id\": 1 }\n },\n \"actions\": {\n \"pages\": { \"id\": 2 }\n }\n}","expected_output":"{\n \"actions\": {\n \"pages\": {\n \"id\": 2\n }\n }\n}\n","validation_input":"{\n \"pages\": {\n \"title\": \"Home\"\n },\n \"users\": [\n { \"name\": \"Alice\" }\n ],\n \"settings\": {\n \"theme\": \"dark\"\n }\n}","validation_output":"{\n \"users\": [\n {\n \"name\": \"Alice\"\n }\n ],\n \"settings\": {\n \"theme\": \"dark\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47023795/removing-a-key-from-parent-object-with-jq","question_title":"Removing a key from parent object with jq","question_owner":"Nicholas","answer_owner":"jq170727","answer_id":47024050,"question_score":44,"reviewed":true}
47
+ {"id":"so-48426052","request":"Given a JSON array of user objects, extract and print the 'username' field from each object on a new line.","command":"jq -r '.[].username'","input_text":"[\n {\n \"username\": \"jdoe\",\n \"name\": \"John Doe\"\n },\n {\n \"username\": \"jadoe\",\n \"name\": \"Jane Doe\"\n }\n]","expected_output":"jdoe\njadoe\n","validation_input":"[\n {\n \"username\": \"alice\",\n \"name\": \"Alice Smith\"\n },\n {\n \"username\": \"bob\",\n \"name\": \"Bob Jones\"\n }\n]","validation_output":"alice\nbob\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48426052/how-to-extract-a-field-from-each-object-in-an-array-with-jq","question_title":"How to extract a field from each object in an array with jq?","question_owner":"Chris F","answer_owner":"John Kugelman","answer_id":48426543,"question_score":84,"reviewed":true}
48
+ {"id":"so-49632521","request":"Add a new key-value pair '\"operation\": \"delete\"' to the 'fields' object located at .module.data.item_i77f664a2.fields in a JSON object.","command":"jq '.module.data.item_i77f664a2.fields += {\"operation\": \"delete\"}'","input_text":"{\"success\": true, \"module\": {\"data\": {\"item_i77f664a2\": {\"id\": \"i77f664a2\", \"fields\": {\"cartItemId\": 2012636322}, \"type\": \"biz\"}}}}","expected_output":"{\n \"success\": true,\n \"module\": {\n \"data\": {\n \"item_i77f664a2\": {\n \"id\": \"i77f664a2\",\n \"fields\": {\n \"cartItemId\": 2012636322,\n \"operation\": \"delete\"\n },\n \"type\": \"biz\"\n }\n }\n }\n}\n","validation_input":"{\"success\": false, \"module\": {\"data\": {\"item_i77f664a2\": {\"id\": \"other-id\", \"fields\": {\"qty\": 5}, \"type\": \"retail\"}}}}","validation_output":"{\n \"success\": false,\n \"module\": {\n \"data\": {\n \"item_i77f664a2\": {\n \"id\": \"other-id\",\n \"fields\": {\n \"qty\": 5,\n \"operation\": \"delete\"\n },\n \"type\": \"retail\"\n }\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49632521/how-to-add-a-field-to-a-json-object-with-the-jq-command","question_title":"How to add a field to a JSON object with the jq command?","question_owner":"Joe","answer_owner":"peak","answer_id":49632947,"question_score":46,"reviewed":true}
49
+ {"id":"so-50868203","request":"Filter a JSON array of objects to keep only those where the 'Address' field starts with a digit.","command":"jq '[.[] | select(.Address | test(\"^[0-9]\"))]'","input_text":"[{\"Address\": \"The Sq\"}, {\"Address\": \"1 Bridge Rd\"}]","expected_output":"[\n {\n \"Address\": \"1 Bridge Rd\"\n }\n]\n","validation_input":"[{\"Address\": \"No Number St\"}, {\"Address\": \"99 Main Ave\"}, {\"Address\": \"Apt 5\"}]","validation_output":"[\n {\n \"Address\": \"99 Main Ave\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50868203/filter-by-regex-in-jq","question_title":"Filter by Regex in JQ","question_owner":"user49","answer_owner":"peak","answer_id":50868294,"question_score":48,"reviewed":true}
50
+ {"id":"so-52065570","request":"Read a stream of JSON objects from stdin, extract the 'duration' field from each, and output the sum of all durations as a single number.","command":"jq -s '[.[].duration] | add'","input_text":"{\"duration\": 1211789}\n{\"duration\": 1211789}\n{\"duration\": 373585}","expected_output":"2797163\n","validation_input":"{\"duration\": 100}\n{\"duration\": 200}\n{\"duration\": 300}","validation_output":"600\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52065570/how-do-i-sum-all-numbers-from-output-of-jq","question_title":"How do I sum all numbers from output of jq","question_owner":"toy","answer_owner":"Charles Duffy","answer_id":52065738,"question_score":40,"reviewed":true}
evaluation/jqweave-0.5b.jsonl ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"id":"so-18592173","request":"From a JSON object where values are objects containing 'name' and 'location', select only those objects where 'location' is 'Stockholm' and output their 'name' values.","command":"jq -r '.[] | select(.location == \"Stockholm\") | .name'","input_text":"{\"FOO\": {\"name\": \"Donald\", \"location\": \"Stockholm\"}, \"BAR\": {\"name\": \"Walt\", \"location\": \"Stockholm\"}, \"BAZ\": {\"name\": \"Jack\", \"location\": \"Whereever\"}}","expected_output":"Donald\nWalt\n","validation_input":"{\"A\": {\"name\": \"Alice\", \"location\": \"Stockholm\"}, \"B\": {\"name\": \"Bob\", \"location\": \"London\"}}","validation_output":"Alice\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq","question_title":"Select objects based on value of variable in object using jq","question_owner":"Daniel","answer_owner":"Daniel","answer_id":18608100,"question_score":557,"reviewed":true,"prediction":"jq '[.[] | select(.location == \"Stockholm\")].name'","valid":false,"correct":false,"error":"jq: error (at <stdin>:0): Cannot index array with string \"name\""}
2
+ {"id":"so-1955505","request":"Extract the value of the 'text' field from a JSON object.","command":"jq -r '.text'","input_text":"{\"text\": \"My status\", \"favorited\": false}","expected_output":"My status\n","validation_input":"{\"text\": \"Another update\", \"favorited\": true}","validation_output":"Another update\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools","question_title":"Parsing JSON with Unix tools","question_owner":"auser","answer_owner":"Brian Campbell","answer_id":1955555,"question_score":1322,"reviewed":true,"prediction":"jq '.text'","valid":true,"correct":false,"error":null}
3
+ {"id":"so-19573517","request":"Select and output only the objects from the input stream where the 'geo' field is not null.","command":"jq 'select(.geo != null)'","input_text":"{\"geo\": {\"lat\": 1.0}}\n{\"geo\": null}\n{\"geo\": {\"lat\": 2.0}}","expected_output":"{\n \"geo\": {\n \"lat\": 1\n }\n}\n{\n \"geo\": {\n \"lat\": 2\n }\n}\n","validation_input":"{\"geo\": null}\n{\"geo\": {\"lng\": 5.0}}\n{\"geo\": null}","validation_output":"{\n \"geo\": {\n \"lng\": 5\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/19573517/jq-conditional-output","question_title":"jq Conditional output","question_owner":"clwen","answer_owner":"max taldykin","answer_id":20489951,"question_score":120,"reviewed":true,"prediction":"jq '[.[] | select(.geo != null)]'","valid":true,"correct":false,"error":null}
4
+ {"id":"so-20181467","request":"Convert a JSON object with dynamic keys into CSV format, where each line contains the key and value quoted and separated by a comma.","command":"jq -r 'to_entries[] | [.key, .value] | @csv'","input_text":"{\"123\":\"abc\",\"231\":\"dbh\",\"452\":\"xyz\"}","expected_output":"\"123\",\"abc\"\n\"231\",\"dbh\"\n\"452\",\"xyz\"\n","validation_input":"{\"a\":\"1\",\"b\":\"2\"}","validation_output":"\"a\",\"1\"\n\"b\",\"2\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/20181467/how-to-map-an-object-to-arrays-so-it-can-be-converted-to-csv","question_title":"How to map an object to arrays so it can be converted to csv?","question_owner":"lsl","answer_owner":"Jeff Mercado","answer_id":24254365,"question_score":54,"reviewed":true,"prediction":"jq 'to_csv'","valid":false,"correct":false,"error":"jq: error: to_csv/0 is not defined at <top-level>, line 1:\nto_csv\njq: 1 compile error"}
5
+ {"id":"so-21334348","request":"Count the number of items in the top-level JSON array.","command":"jq length","input_text":"[\n {\n \"cid\": 49,\n \"pyn\": \"yi4\",\n \"hans\": \"亿\",\n \"hant\": \"億\",\n \"tid\": 68,\n \"l10n\": \"cent million\",\n \"pid\": 1,\n \"pos\": \"num\",\n \"pos_txt\": \"\"\n },\n {\n \"cid\": 50,\n \"pyn\": \"yi4\",\n \"hans\": \"亿\",\n \"hant\": \"億\",\n \"tid\": 69,\n \"l10n\": \"100 millions\",\n \"pid\": 1,\n \"pos\": \"num\",\n \"pos_txt\": \"\"\n }\n]","expected_output":"2\n","validation_input":"[\n {\n \"id\": 1\n },\n {\n \"id\": 2\n },\n {\n \"id\": 3\n }\n]","validation_output":"3\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/21334348/how-to-count-items-in-json-object-using-command-line","question_title":"How to count items in JSON object using command line?","question_owner":"&#201;douard Lopez","answer_owner":"Ken","answer_id":21355442,"question_score":476,"reviewed":true,"prediction":"jq 'length'","valid":true,"correct":true,"error":null}
6
+ {"id":"so-23118341","request":"Extract the keys from the JSON object as a sorted array of strings.","command":"jq keys","input_text":"{\n \"email\": \"madireddy@test.com\",\n \"versionID\": \"2323\",\n \"context\": \"test\",\n \"date\": \"02-03-2014-13:41\",\n \"versionName\": \"application\"\n}","expected_output":"[\n \"context\",\n \"date\",\n \"email\",\n \"versionID\",\n \"versionName\"\n]\n","validation_input":"{\n \"Created-By\": \"Apache Maven\",\n \"Build-Number\": \"\",\n \"Archiver-Version\": \"Plexus Archiver\"\n}","validation_output":"[\n \"Archiver-Version\",\n \"Build-Number\",\n \"Created-By\"\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/23118341/how-to-get-key-names-from-json-using-jq","question_title":"How to get key names from JSON using jq","question_owner":"Ezhilan Mahalingam","answer_owner":"anubhava","answer_id":23118607,"question_score":314,"reviewed":true,"prediction":"jq 'keys'","valid":true,"correct":true,"error":null}
7
+ {"id":"so-24698188","request":"Given a JSON array of objects, flatten each object by removing the 'fields' key and promoting its values (taking the first element if they are arrays) to the top level, while preserving other top-level keys.","command":"jq 'map(with_entries(select(.key != \"fields\")) + (.fields | with_entries(.value = .value[0])))'","input_text":"[\n {\n \"index\": \"index1\",\n \"type\": \"type1\",\n \"id\": \"id1\",\n \"fields\": {\n \"deviceOs\": [\"Android\"],\n \"deviceID\": [\"deviceID1\"],\n \"country\": [\"DE\"]\n }\n },\n {\n \"index\": \"index2\",\n \"type\": \"type2\",\n \"id\": \"id2\",\n \"fields\": {\n \"deviceOs\": [\"iOS\"],\n \"deviceID\": [\"deviceID2\"],\n \"country\": [\"US\"]\n }\n }\n]","expected_output":"[\n {\n \"index\": \"index1\",\n \"type\": \"type1\",\n \"id\": \"id1\",\n \"deviceOs\": \"Android\",\n \"deviceID\": \"deviceID1\",\n \"country\": \"DE\"\n },\n {\n \"index\": \"index2\",\n \"type\": \"type2\",\n \"id\": \"id2\",\n \"deviceOs\": \"iOS\",\n \"deviceID\": \"deviceID2\",\n \"country\": \"US\"\n }\n]\n","validation_input":"[\n {\n \"index\": \"idx1\",\n \"val\": \"v1\",\n \"fields\": {\n \"a\": [\"x\"],\n \"b\": [\"y\"]\n }\n }\n]","validation_output":"[\n {\n \"index\": \"idx1\",\n \"val\": \"v1\",\n \"a\": \"x\",\n \"b\": \"y\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/24698188/flatten-a-json-document-using-jq","question_title":"Flatten a JSON document using jq","question_owner":"Dror","answer_owner":"Jeff Mercado","answer_id":24710337,"question_score":39,"reviewed":true,"prediction":"jq 'flatten(.fields[] | first)'","valid":false,"correct":false,"error":"jq: error (at <stdin>:21): Cannot index array with string \"fields\""}
8
+ {"id":"so-25378013","request":"Convert a JSON object into a list of strings where each string is formatted as \"key=value\".","command":"jq -r 'to_entries|map(\"\\(.key)=\\(.value|tostring)\")|.[]'","input_text":"{\n \"var\": 1,\n \"foo\": \"bar\",\n \"x\": \"test\"\n}","expected_output":"var=1\nfoo=bar\nx=test\n","validation_input":"{\n \"name\": \"Alice\",\n \"age\": 30,\n \"active\": true\n}","validation_output":"name=Alice\nage=30\nactive=true\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/25378013/how-to-convert-a-json-object-to-key-value-format-in-jq","question_title":"How to convert a JSON object to key=value format in jq?","question_owner":"gianebao","answer_owner":"aioobe","answer_id":25378171,"question_score":75,"reviewed":true,"prediction":"jq 'to_entries'","valid":true,"correct":false,"error":null}
9
+ {"id":"so-26701538","request":"From a JSON array of objects each having an 'Id' string and a 'Names' array of strings, filter out any object where any name in 'Names' contains the substring 'data', and output the 'Id' of the remaining objects.","command":"jq -r '.[] | select(.Names | all(contains(\"data\") | not)) | .Id'","input_text":"[{\"Id\": \"abc\", \"Names\": [\"condescending_jones\"]}, {\"Id\": \"def\", \"Names\": [\"foo_data\"]}]","expected_output":"abc\n","validation_input":"[{\"Id\": \"123\", \"Names\": [\"jovial_wozniak\"]}, {\"Id\": \"456\", \"Names\": [\"bar_data\"]}, {\"Id\": \"mix\", \"Names\": [\"foo_data\", \"safe\"]}]","validation_output":"123\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/26701538/jq-how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array","question_title":"jq: how to filter an array of objects based on values in an inner array?","question_owner":"Abe Voelker","answer_owner":"Iain Samuel McLean Elder","answer_id":26701851,"question_score":518,"reviewed":true,"prediction":"jq '[.[] | select(not any(.Names | index(\"data\") >= 0))]'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected IDENT, expecting ';' or ')' (Unix shell quoting issues?) at <top-level>, line 1:\n[.[] | select(not any(.Names | index(\"data\") >= 0))] \njq: 1 compile error"}
10
+ {"id":"so-27562424","request":"For each object in the input array, create a new object containing the top-level id and the value of info-spec from the nested stuff object.","command":"jq '[.[] | {id, \"info-spec\": .stuff[\"info-spec\"]}]'","input_text":"[{\"id\": 12345678, \"stuff\": {\"book\": \"shelf\", \"hook\": \"line\", \"took\": \"off\", \"info-spec\": 12}, \"votes\": 23}, {\"id\": 12345679, \"stuff\": {\"book\": \"maker\", \"hook\": \"sinker\", \"took\": \"pisin\", \"info-spec\": 23}, \"votes\": 1}]","expected_output":"[\n {\n \"id\": 12345678,\n \"info-spec\": 12\n },\n {\n \"id\": 12345679,\n \"info-spec\": 23\n }\n]\n","validation_input":"[{\"id\": 999, \"stuff\": {\"info-spec\": 100, \"other\": \"val\"}}, {\"id\": 888, \"stuff\": {\"info-spec\": 200, \"other\": \"val2\"}}]","validation_output":"[\n {\n \"id\": 999,\n \"info-spec\": 100\n },\n {\n \"id\": 888,\n \"info-spec\": 200\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/27562424/jq-nested-object-extract-top-level-id-and-lift-a-value-from-internal-object","question_title":"jq: nested object, extract top-level id and lift a value from internal object","question_owner":"tripleee","answer_owner":"tripleee","answer_id":27562901,"question_score":42,"reviewed":true,"prediction":"jq '[.[] | {id: .stuff.info-spec, info: .stuff}]'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected '-', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:\n[.[] | {id: .stuff.info-spec, info: .stuff}] \njq: 1 compile error"}
11
+ {"id":"so-28484534","request":"Read a stream of JSON objects and output a single object where each key's value is the sum of that key's values across all input objects.","command":"jq -s '[.[] | to_entries] | add | group_by(.key) | map({key: .[0].key, value: map(.value) | add}) | from_entries'","input_text":"{ \"a\": 10, \"b\": 11 }\n{ \"a\": 20, \"b\": 21 }","expected_output":"{\n \"a\": 30,\n \"b\": 32\n}\n","validation_input":"{ \"x\": 5, \"y\": 10 }\n{ \"x\": 15, \"y\": 20 }\n{ \"x\": 0, \"y\": 5 }","validation_output":"{\n \"x\": 20,\n \"y\": 35\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/28484534/how-do-i-sum-the-values-in-an-array-of-maps-in-jq","question_title":"How do I sum the values in an array of maps in jq?","question_owner":"Alan Burlison","answer_owner":"Jeff Mercado","answer_id":28485485,"question_score":46,"reviewed":true,"prediction":"jq '{sum: .[] | .a + .b}'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected '+', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:\n{sum: .[] | .a + .b} \njq: 1 compile error"}
12
+ {"id":"so-29404575","request":"Convert a stream of JSON objects into a single JSON array containing all the objects.","command":"jq -s '.'","input_text":"{\"a\":1}\n{\"b\":2}","expected_output":"[\n {\n \"a\": 1\n },\n {\n \"b\": 2\n }\n]\n","validation_input":"{\"x\":\"foo\"}\n{\"y\":\"bar\"}\n{\"z\":123}","validation_output":"[\n {\n \"x\": \"foo\"\n },\n {\n \"y\": \"bar\"\n },\n {\n \"z\": 123\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29404575/how-to-convert-a-json-object-stream-into-an-array-with-jq","question_title":"How to convert a JSON object stream into an array with jq","question_owner":"Qiang Li","answer_owner":"Jeff Mercado","answer_id":29404613,"question_score":46,"reviewed":true,"prediction":"jq 'flatten'","valid":true,"correct":false,"error":null}
13
+ {"id":"so-29949184","request":"Filter a JSON object to keep only items with id \"123\" in the \"requests\" array if it exists and is non-empty, otherwise output nothing.","command":"jq 'if (.requests | length) != 0 then .requests |= map(select(.id == \"123\")) else empty end'","input_text":"{\"requests\":[{\"id\":\"123\"},{\"id\":\"456\"}]}","expected_output":"{\n \"requests\": [\n {\n \"id\": \"123\"\n }\n ]\n}\n","validation_input":"{\"requests\":[{\"id\":\"789\"}]}","validation_output":"{\n \"requests\": []\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/29949184/json-jq-if-without-else","question_title":"JSON JQ if without else","question_owner":"user1578872","answer_owner":"peak","answer_id":29962258,"question_score":53,"reviewed":true,"prediction":"jq '[.requests[] | select(.id == \"123\")]'","valid":true,"correct":false,"error":null}
14
+ {"id":"so-31034746","request":"Set the value of the key \"local\" inside the \"shipping\" object to false, preserving the rest of the JSON structure.","command":"jq '.shipping.local = false'","input_text":"{\"shipping\": {\"local\": true, \"us\": true, \"us_rate\": {\"amount\": \"0.00\", \"currency\": \"USD\", \"symbol\": \"$\"}}}","expected_output":"{\n \"shipping\": {\n \"local\": false,\n \"us\": true,\n \"us_rate\": {\n \"amount\": \"0.00\",\n \"currency\": \"USD\",\n \"symbol\": \"$\"\n }\n }\n}\n","validation_input":"{\"shipping\": {\"local\": true, \"international\": false}, \"other\": \"data\"}","validation_output":"{\n \"shipping\": {\n \"local\": false,\n \"international\": false\n },\n \"other\": \"data\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/31034746/how-do-i-update-a-single-value-in-a-json-document-using-jq","question_title":"How do I update a single value in a json document using jq?","question_owner":"STW","answer_owner":"Jeff Mercado","answer_id":31037640,"question_score":231,"reviewed":true,"prediction":"jq '{shipping: .shipping.us = false}'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected '=', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:\n{shipping: .shipping.us = false} \njq: 1 compile error"}
15
+ {"id":"so-33247228","request":"Pretty-print the input JSON using jq's default formatting.","command":"jq '.'","input_text":"{\"name\": \"octocat\", \"id\": 1}","expected_output":"{\n \"name\": \"octocat\",\n \"id\": 1\n}\n","validation_input":"{\"key\": \"value\", \"nested\": {\"a\": 1}}","validation_output":"{\n \"key\": \"value\",\n \"nested\": {\n \"a\": 1\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33247228/how-to-use-jq-in-a-shell-pipeline","question_title":"How to use `jq` in a shell pipeline?","question_owner":"mgalgs","answer_owner":"chepner","answer_id":33247259,"question_score":244,"reviewed":true,"prediction":"jq 'prettyprint'","valid":false,"correct":false,"error":"jq: error: prettyprint/0 is not defined at <top-level>, line 1:\nprettyprint\njq: 1 compile error"}
16
+ {"id":"so-33895076","request":"Given a JSON array of objects containing 'timestamp', 'group', and 'uid' fields, output each object's 'group' and 'uid' values joined by a comma on separate lines.","command":"jq -r '.[]|[.group,.uid]|join(\",\")'","input_text":"[\n {\n \"timestamp\": 1448369447295,\n \"group\": \"employees\",\n \"uid\": \"elgalu\"\n },\n {\n \"timestamp\": 1448369447296,\n \"group\": \"employees\",\n \"uid\": \"mike\"\n },\n {\n \"timestamp\": 1448369786667,\n \"group\": \"services\",\n \"uid\": \"pacts\"\n }\n]","expected_output":"employees,elgalu\nemployees,mike\nservices,pacts\n","validation_input":"[\n {\n \"timestamp\": 100,\n \"group\": \"admin\",\n \"uid\": \"root\"\n },\n {\n \"timestamp\": 200,\n \"group\": \"users\",\n \"uid\": \"guest\"\n }\n]","validation_output":"admin,root\nusers,guest\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33895076/exclude-column-from-jq-json-output","question_title":"Exclude column from jq json output","question_owner":"Leo Gallucci","answer_owner":"hek2mgl","answer_id":33895231,"question_score":87,"reviewed":true,"prediction":"jq -r '.[] | [.group,.uid] | join(\", \")'","valid":true,"correct":false,"error":null}
17
+ {"id":"so-33947584","request":"Extract start_id and end_id from each JSON object and print them on the same line separated by a space, without surrounding double quotes.","command":"jq -r '\"\\(.start_id) \\(.end_id)\"'","input_text":"{\"start_id\":1,\"end_id\":50}\n{\"start_id\":50,\"end_id\":99}\n{\"start_id\":99,\"end_id\":12}","expected_output":"1 50\n50 99\n99 12\n","validation_input":"{\"start_id\":10,\"end_id\":20}\n{\"start_id\":20,\"end_id\":30}","validation_output":"10 20\n20 30\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/33947584/concat-numbers-from-json-without-doublequotes-using-jq","question_title":"Concat numbers from JSON without doublequotes using jq","question_owner":"Synesso","answer_owner":"xjedam","answer_id":33952189,"question_score":39,"reviewed":true,"prediction":"jq '.[] | .start_id,.end_id'","valid":false,"correct":false,"error":"jq: error (at <stdin>:1): Cannot index number with string \"start_id\"\njq: error (at <stdin>:2): Cannot index number with string \"start_id\"\njq: error (at <stdin>:2): Cannot index number with string \"start_id\""}
18
+ {"id":"so-34226370","request":"Given a JSON object where keys are hostnames and values are objects containing an 'ip' field, output each hostname and its corresponding IP address as a comma-separated string on separate lines.","command":"jq -r 'to_entries[] | \"\\(.key), \\(.value.ip)\"'","input_text":"{\n \"host1\": { \"ip\": \"10.1.2.3\" },\n \"host2\": { \"ip\": \"10.1.2.2\" },\n \"host3\": { \"ip\": \"10.1.18.1\" }\n}","expected_output":"host1, 10.1.2.3\nhost2, 10.1.2.2\nhost3, 10.1.18.1\n","validation_input":"{\n \"serverA\": { \"ip\": \"192.168.1.1\" },\n \"serverB\": { \"ip\": \"192.168.1.2\" }\n}","validation_output":"serverA, 192.168.1.1\nserverB, 192.168.1.2\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34226370/jq-print-key-and-value-for-each-entry-in-an-object","question_title":"jq: print key and value for each entry in an object","question_owner":"Jeff Tang","answer_owner":"peak","answer_id":34227629,"question_score":164,"reviewed":true,"prediction":"jq -r '.[] | .ip'","valid":true,"correct":false,"error":null}
19
+ {"id":"so-34340549","request":"Parse the JSON string contained in the \"text\" field of the \"response\" object and extract the \"title\" field from the parsed JSON.","command":"jq '.response.text | fromjson | .title'","input_text":"{\n \"requestType\": \"POST\",\n \"response\": {\n \"size\": 78,\n \"text\": \"{\\\"recordID\\\":123, \\\"title\\\":\\\"Hello World\\\", \\\"content\\\":\\\"Lorem ipsum...\\\"}\"\n }\n}","expected_output":"\"Hello World\"\n","validation_input":"{\n \"requestType\": \"GET\",\n \"response\": {\n \"size\": 50,\n \"text\": \"{\\\"id\\\":456, \\\"title\\\":\\\"Goodbye World\\\", \\\"data\\\":null}\"\n }\n}","validation_output":"\"Goodbye World\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34340549/convert-string-to-json-in-jq","question_title":"Convert string to json in jq","question_owner":"RJ-Adam","answer_owner":"Jeff Mercado","answer_id":34340787,"question_score":100,"reviewed":true,"prediction":"jq '.response.text.title'","valid":false,"correct":false,"error":"jq: error (at <stdin>:6): Cannot index string with string \"title\""}
20
+ {"id":"so-34543829","request":"Extract the 'def' value from the 'aux' array within each object of the top-level array.","command":"jq -r '.[].aux[].def'","input_text":"[{\"id\": 123, \"name\": \"John\", \"aux\": [{\"abc\": \"random\", \"def\": \"I want this\"}], \"blah\": 23.11}]","expected_output":"I want this\n","validation_input":"[{\"id\": 456, \"name\": \"Jane\", \"aux\": [{\"abc\": \"x\", \"def\": \"Target Value\"}], \"blah\": 10.0}]","validation_output":"Target Value\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/34543829/jq-cannot-index-array-with-string","question_title":"jq: Cannot index array with string","question_owner":"Xu Wang","answer_owner":"hek2mgl","answer_id":34544406,"question_score":115,"reviewed":true,"prediction":"jq '.[] | .aux[0].def'","valid":true,"correct":false,"error":null}
21
+ {"id":"so-35086391","request":"Given a JSON object where values are objects with a single key, output all the inner keys as a stream of strings.","command":"jq '.[] | keys[]'","input_text":"{\n \"keyword1\": {\n \"identifier1\": 16\n },\n \"keyword2\": {\n \"identifier2\": 16\n }\n}","expected_output":"\"identifier1\"\n\"identifier2\"\n","validation_input":"{\n \"groupA\": {\n \"nameA\": 1\n },\n \"groupB\": {\n \"nameB\": 2\n }\n}","validation_output":"\"nameA\"\n\"nameB\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35086391/jq-how-to-iterate-through-keys-of-different-names","question_title":"jq - How to iterate through keys of different names","question_owner":"Adam vonNieda","answer_owner":"peak","answer_id":35091473,"question_score":40,"reviewed":true,"prediction":"jq 'keys'","valid":true,"correct":false,"error":null}
22
+ {"id":"so-35154684","request":"Parse the JSON string contained in the field \"c\" and extract the value of its \"id\" field.","command":"jq '.c | fromjson | .id'","input_text":"{\"a\": 1, \"b\": 2, \"c\": \"{\\\"id\\\":\\\"9ee\\\",\\\"parent\\\":\\\"abc\\\"}\"}","expected_output":"\"9ee\"\n","validation_input":"{\"x\": 10, \"c\": \"{\\\"id\\\":\\\"xyz123\\\",\\\"type\\\":\\\"user\\\"}\"}","validation_output":"\"xyz123\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35154684/how-to-parse-a-json-string-with-jq-or-other-alternatives","question_title":"how to parse a JSON String with jq (or other alternatives)?","question_owner":"Colin Grogan","answer_owner":"jwodder","answer_id":35155249,"question_score":217,"reviewed":true,"prediction":"jq '.c.id'","valid":false,"correct":false,"error":"jq: error (at <stdin>:0): Cannot index string with string \"id\""}
23
+ {"id":"so-35677309","request":"Extract the \"AssetId\" value from each object in a JSON array and output them as raw strings.","command":"jq -r '.[] | .AssetId'","input_text":"[\n {\n \"AssetId\": 14462955,\n \"Name\": \"Cultural Item\"\n },\n {\n \"AssetId\": 114385498,\n \"Name\": \"Redspybot\"\n },\n {\n \"AssetId\": 29715011,\n \"Name\": \"American Cowboy\"\n },\n {\n \"AssetId\": 98253651,\n \"Name\": \"Mahem\"\n }\n]","expected_output":"14462955\n114385498\n29715011\n98253651\n","validation_input":"[\n {\n \"AssetId\": 100,\n \"Name\": \"Item A\"\n },\n {\n \"AssetId\": 200,\n \"Name\": \"Item B\"\n }\n]","validation_output":"100\n200\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/35677309/output-specific-key-value-in-object-for-each-element-in-array-with-jq-for-json","question_title":"Output specific key value in object for each element in array with jq for JSON","question_owner":"Zimbabwe Elephant","answer_owner":"peak","answer_id":35677443,"question_score":98,"reviewed":true,"prediction":"jq '.[] | .AssetId'","valid":true,"correct":true,"error":null}
24
+ {"id":"so-36227245","request":"Remove the keys \"Country\", \"number\", and \"Language\" from each object in a JSON array.","command":"jq 'map(del(.Country, .number, .Language))'","input_text":"[\n {\n \"label\": \"US : USA : English\",\n \"Country\": \"USA\",\n \"region\": \"US\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"USD\",\n \"number\": \"USD\"\n },\n {\n \"label\": \"AU : Australia : English\",\n \"Country\": \"Australia\",\n \"region\": \"AU\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"AUD\",\n \"number\": \"AUD\"\n }\n]","expected_output":"[\n {\n \"label\": \"US : USA : English\",\n \"region\": \"US\",\n \"locale\": \"en\",\n \"currency\": \"USD\"\n },\n {\n \"label\": \"AU : Australia : English\",\n \"region\": \"AU\",\n \"locale\": \"en\",\n \"currency\": \"AUD\"\n }\n]\n","validation_input":"[\n {\n \"label\": \"CA : Canada : English\",\n \"Country\": \"Canada\",\n \"region\": \"CA\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"CAD\",\n \"number\": \"CAD\"\n },\n {\n \"label\": \"GB : UK : English\",\n \"Country\": \"UK\",\n \"region\": \"GB\",\n \"Language\": \"English\",\n \"locale\": \"en\",\n \"currency\": \"GBP\",\n \"number\": \"GBP\"\n }\n]","validation_output":"[\n {\n \"label\": \"CA : Canada : English\",\n \"region\": \"CA\",\n \"locale\": \"en\",\n \"currency\": \"CAD\"\n },\n {\n \"label\": \"GB : UK : English\",\n \"region\": \"GB\",\n \"locale\": \"en\",\n \"currency\": \"GBP\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/36227245/deleting-multiple-keys-at-once-with-jq","question_title":"Deleting multiple keys at once with jq","question_owner":"antun","answer_owner":"user3899165","answer_id":36228054,"question_score":79,"reviewed":true,"prediction":"jq 'del(.Country,.number,.Language)'","valid":false,"correct":false,"error":"jq: error (at <stdin>:19): Cannot index array with string \"Country\""}
25
+ {"id":"so-37344329","request":"Extract the value of the key \"component-status\" from a JSON object.","command":"jq '.\"component-status\"'","input_text":"{\n \"status\": \"ok\",\n \"hostname\": \"0b0b495a46db\",\n \"component-status\": [\n {\n \"status-code\": 200,\n \"component\": \"Service1\",\n \"status\": \"OK\"\n },\n {\n \"status-code\": 200,\n \"component\": \"Service2\",\n \"status\": \"OK\"\n }\n ]\n}","expected_output":"[\n {\n \"status-code\": 200,\n \"component\": \"Service1\",\n \"status\": \"OK\"\n },\n {\n \"status-code\": 200,\n \"component\": \"Service2\",\n \"status\": \"OK\"\n }\n]\n","validation_input":"{\n \"status\": \"error\",\n \"hostname\": \"test-host\",\n \"component-status\": [\n {\n \"status-code\": 500,\n \"component\": \"DB\",\n \"status\": \"FAIL\"\n }\n ]\n}","validation_output":"[\n {\n \"status-code\": 500,\n \"component\": \"DB\",\n \"status\": \"FAIL\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37344329/jq-not-working-on-tag-name-with-dashes-and-numbers","question_title":"jq not working on tag name with dashes and numbers","question_owner":"paul","answer_owner":"fedorqui","answer_id":37344498,"question_score":102,"reviewed":true,"prediction":"jq '.component-status[0].status-code'","valid":false,"correct":false,"error":"jq: error: status/0 is not defined at <top-level>, line 1:\n.component-status[0].status-code \njq: error: code/0 is not defined at <top-level>, line 1:\n.component-status[0].status-code \njq: 2 compile errors"}
26
+ {"id":"so-37563691","request":"Extract the md5 value from the object in the files array where the fileName is \"FOO\".","command":"jq -r '.files[] | select(.fileName==\"FOO\") | .md5'","input_text":"{\"files\": [{\"fileName\": \"FOO\", \"md5\": \"blablabla\"}, {\"fileName\": \"BAR\", \"md5\": \"alaldlafj\"}]}","expected_output":"blablabla\n","validation_input":"{\"files\": [{\"fileName\": \"TEST\", \"md5\": \"abc123\"}, {\"fileName\": \"FOO\", \"md5\": \"xyz789\"}, {\"fileName\": \"BAZ\", \"md5\": \"def456\"}]}","validation_output":"xyz789\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37563691/jq-select-value-from-array","question_title":"jq select value from array","question_owner":"Marvin Effing","answer_owner":"Marvin Effing","answer_id":37567004,"question_score":82,"reviewed":true,"prediction":"jq '.files[] | .md5'","valid":true,"correct":false,"error":null}
27
+ {"id":"so-37577683","request":"Extract the value of the 'hostName' field from all top-level values in a JSON object, regardless of the top-level keys.","command":"jq -r '.[].hostName'","input_text":"{\"key1\": {\"hostName\": \"server1\", \"state\": \"READY\"}, \"key2\": {\"hostName\": \"server2\", \"state\": \"STOPPED\"}}","expected_output":"server1\nserver2\n","validation_input":"{\"abc-123\": {\"hostName\": \"node-alpha\", \"ip\": \"10.0.0.1\"}, \"xyz-789\": {\"hostName\": \"node-beta\", \"ip\": \"10.0.0.2\"}}","validation_output":"node-alpha\nnode-beta\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37577683/how-to-use-jq-to-obtain-the-keys","question_title":"How to use `jq` to obtain the keys","question_owner":"sudhishkr","answer_owner":"Andreas Louv","answer_id":37577805,"question_score":47,"reviewed":true,"prediction":"jq '.[] | .hostName'","valid":true,"correct":false,"error":null}
28
+ {"id":"so-37710718","request":"Create a new JSON object containing a single field named 'channel' whose value is the concatenation of the input's 'profile_type', a dot, and the input's 'channel' value.","command":"jq '{channel: (.profile_type + \".\" + .channel)}'","input_text":"{\"channel\": \"youtube\", \"profile_type\": \"video\", \"member_key\": \"hello\"}","expected_output":"{\n \"channel\": \"video.youtube\"\n}\n","validation_input":"{\"channel\": \"twitch\", \"profile_type\": \"stream\", \"member_key\": \"world\"}","validation_output":"{\n \"channel\": \"stream.twitch\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/37710718/concat-2-fields-in-json-using-jq","question_title":"Concat 2 fields in JSON using jq","question_owner":"darthsidious","answer_owner":"Anthony Battaglia","answer_id":37710802,"question_score":177,"reviewed":true,"prediction":"jq '.channel + '.' + .profile_type'","valid":false,"correct":false,"error":"jq: error (at <stdin>:0): string (\"youtube\") and object ({\"channel\":...) cannot be added"}
29
+ {"id":"so-38061346","request":"Read a stream of multiple JSON objects from stdin and combine them into a single JSON array.","command":"jq -s '.'","input_text":"{\"name\": \"John\", \"email\": \"john@company.com\"}\n{\"name\": \"Brad\", \"email\": \"brad@company.com\"}","expected_output":"[\n {\n \"name\": \"John\",\n \"email\": \"john@company.com\"\n },\n {\n \"name\": \"Brad\",\n \"email\": \"brad@company.com\"\n }\n]\n","validation_input":"{\"id\": 1, \"status\": \"active\"}\n{\"id\": 2, \"status\": \"inactive\"}\n{\"id\": 3, \"status\": \"pending\"}","validation_output":"[\n {\n \"id\": 1,\n \"status\": \"active\"\n },\n {\n \"id\": 2,\n \"status\": \"inactive\"\n },\n {\n \"id\": 3,\n \"status\": \"pending\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38061346/jq-output-array-of-json-objects","question_title":"jq: output array of json objects","question_owner":"Mauricio Trajano","answer_owner":"chepner","answer_id":38061430,"question_score":134,"reviewed":true,"prediction":"jq 'concat'","valid":false,"correct":false,"error":"jq: error: concat/0 is not defined at <top-level>, line 1:\nconcat\njq: 1 compile error"}
30
+ {"id":"so-38121740","request":"Filter the 'theList' array to include only objects where the 'id' is either 2 or 4.","command":"jq '.theList[] | select(.id == 2 or .id == 4)'","input_text":"{\"theList\": [{\"id\": 1, \"name\": \"Horst\"}, {\"id\": 2, \"name\": \"Fritz\"}, {\"id\": 3, \"name\": \"Walter\"}, {\"id\": 4, \"name\": \"Gerhart\"}, {\"id\": 5, \"name\": \"Harmut\"}]}","expected_output":"{\n \"id\": 2,\n \"name\": \"Fritz\"\n}\n{\n \"id\": 4,\n \"name\": \"Gerhart\"\n}\n","validation_input":"{\"theList\": [{\"id\": 10, \"name\": \"A\"}, {\"id\": 2, \"name\": \"B\"}, {\"id\": 4, \"name\": \"C\"}, {\"id\": 5, \"name\": \"D\"}]}","validation_output":"{\n \"id\": 2,\n \"name\": \"B\"\n}\n{\n \"id\": 4,\n \"name\": \"C\"\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38121740/how-to-filter-array-of-objects-by-element-property-values-using-jq","question_title":"How to filter array of objects by element property values using jq?","question_owner":"k0pernikus","answer_owner":"Andr&#233; Senra","answer_id":38122029,"question_score":120,"reviewed":true,"prediction":"jq '[.theList[] | select(.id == 2 || .id == 4)]'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected '|' (Unix shell quoting issues?) at <top-level>, line 1:\n[.theList[] | select(.id == 2 || .id == 4)] \njq: 1 compile error"}
31
+ {"id":"so-38500363","request":"Select all objects from the input array where the key 'a' equals 'x', collect them into an array, and return the first element of that resulting array.","command":"jq '[.[] | select(.a == \"x\")][0]'","input_text":"[{\"a\": \"x\", \"b\": true}, {\"a\": \"x\", \"b\": false}, {\"a\": \"XML\", \"b\": false}]","expected_output":"{\n \"a\": \"x\",\n \"b\": true\n}\n","validation_input":"[{\"a\": \"y\", \"b\": true}, {\"a\": \"x\", \"b\": 123}, {\"a\": \"x\", \"b\": 456}]","validation_output":"{\n \"a\": \"x\",\n \"b\": 123\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38500363/get-the-first-or-nth-element-in-a-jq-json-parsing","question_title":"get the first (or n&#39;th) element in a jq json parsing","question_owner":"Demian Glait","answer_owner":"hek2mgl","answer_id":38500610,"question_score":128,"reviewed":true,"prediction":"jq '[.[] | select(.a == \"x\")][0]'","valid":true,"correct":true,"error":null}
32
+ {"id":"so-38689645","request":"Select the parent object from a JSON structure where a nested field \"details.name\" equals \"James Brown\".","command":"jq 'select(.details.name == \"James Brown\")'","input_text":"{\n \"id\": 1,\n \"details\": {\n \"username\": \"jamesbrown\",\n \"name\": \"James Brown\"\n }\n}","expected_output":"{\n \"id\": 1,\n \"details\": {\n \"username\": \"jamesbrown\",\n \"name\": \"James Brown\"\n }\n}\n","validation_input":"{\n \"id\": 2,\n \"details\": {\n \"username\": \"janedoe\",\n \"name\": \"Jane Doe\"\n }\n}\n{\n \"id\": 3,\n \"details\": {\n \"username\": \"jamesbrown2\",\n \"name\": \"James Brown\"\n }\n}","validation_output":"{\n \"id\": 3,\n \"details\": {\n \"username\": \"jamesbrown2\",\n \"name\": \"James Brown\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/38689645/how-do-i-print-a-parent-value-of-an-object-when-i-am-already-deep-into-the-objec","question_title":"How do I print a parent value of an object when I am already deep into the object&#39;s children?","question_owner":"x3nr0s","answer_owner":"user3899165","answer_id":38693695,"question_score":75,"reviewed":true,"prediction":"jq '.details.parent'","valid":true,"correct":false,"error":null}
33
+ {"id":"so-39228500","request":"Extract all 'name' values from the array located at '.example.\"sub-example\"' in the input JSON object.","command":"jq '.example.\"sub-example\" | .[] | .name'","input_text":"{\n \"example\": {\n \"sub-example\": [\n {\n \"name\": \"123-345\",\n \"tag\": 100\n },\n {\n \"name\": \"234-456\",\n \"tag\": 100\n },\n {\n \"name\": \"4a7-a07a5\",\n \"tag\": 100\n }\n ]\n }\n}","expected_output":"\"123-345\"\n\"234-456\"\n\"4a7-a07a5\"\n","validation_input":"{\n \"example\": {\n \"sub-example\": [\n {\n \"name\": \"alpha\",\n \"tag\": 200\n },\n {\n \"name\": \"beta\",\n \"tag\": 200\n }\n ]\n }\n}","validation_output":"\"alpha\"\n\"beta\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/39228500/extract-a-specific-field-from-json-output-using-jq","question_title":"Extract a specific field from JSON output using jq","question_owner":"rmb","answer_owner":"aaaaaa123456789","answer_id":39228718,"question_score":160,"reviewed":true,"prediction":"jq '.example.sub-example[] | .name'","valid":false,"correct":false,"error":"jq: error: example/0 is not defined at <top-level>, line 1:\n.example.sub-example[] | .name \njq: 1 compile error"}
34
+ {"id":"so-40396445","request":"Extract the key, status name, and assignee email address from each issue in the input JSON object's issues array, and output each result as a compact JSON object on a single line.","command":"jq -c '.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress}'","input_text":"{\"issues\": [{\"key\": \"SEA-739\", \"fields\": {\"status\": {\"name\": \"Open\"}, \"assignee\": null}}, {\"key\": \"SEA-738\", \"fields\": {\"status\": {\"name\": \"Resolved\"}, \"assignee\": {\"emailAddress\": \"user2@mycompany.com\"}}}]}","expected_output":"{\"key\":\"SEA-739\",\"status\":\"Open\",\"assignee\":null}\n{\"key\":\"SEA-738\",\"status\":\"Resolved\",\"assignee\":\"user2@mycompany.com\"}\n","validation_input":"{\"issues\": [{\"key\": \"PROJ-101\", \"fields\": {\"status\": {\"name\": \"In Progress\"}, \"assignee\": {\"emailAddress\": \"dev@example.com\"}}}, {\"key\": \"PROJ-102\", \"fields\": {\"status\": {\"name\": \"Closed\"}, \"assignee\": null}}]}","validation_output":"{\"key\":\"PROJ-101\",\"status\":\"In Progress\",\"assignee\":\"dev@example.com\"}\n{\"key\":\"PROJ-102\",\"status\":\"Closed\",\"assignee\":null}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/40396445/get-outputs-from-jq-on-a-single-line","question_title":"Get outputs from jq on a single line","question_owner":"Jitesh Sojitra","answer_owner":"hmedia1","answer_id":40396556,"question_score":187,"reviewed":true,"prediction":"jq '.issues[] | .fields | {key: .key, statusName: .fields.status.name, assigneeEmail: .fields.assignee.emailAddress}'","valid":true,"correct":false,"error":null}
35
+ {"id":"so-42051601","request":"From a JSON object with a 'data' field, extract the values of keys that case-insensitively match the pattern 'what a burger'.","command":"jq '.data | to_entries | map(select(.key | match(\"what a burger\";\"i\"))) | map(.value)'","input_text":"{\n \"data\": {\n \"what a burger\": [1, 2, 3],\n \"wap\": [66],\n \"the map\": [11, 20],\n \"H. Incandenza\": [1, 1],\n \"What a burger\": [\"a\", \"a\", 3]\n }\n}","expected_output":"[\n [\n 1,\n 2,\n 3\n ],\n [\n \"a\",\n \"a\",\n 3\n ]\n]\n","validation_input":"{\n \"data\": {\n \"WHAT A BURGER\": [10, 20],\n \"other\": [5],\n \"What a Burger\": [\"x\", \"y\"]\n }\n}","validation_output":"[\n [\n 10,\n 20\n ],\n [\n \"x\",\n \"y\"\n ]\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42051601/pattern-matching-field-names-with-jq","question_title":"Pattern matching field names with jq","question_owner":"manu","answer_owner":"koalo","answer_id":42051804,"question_score":45,"reviewed":true,"prediction":"jq '[.data.what_a_burger[] | .[]]'","valid":false,"correct":false,"error":"jq: error (at <stdin>:8): Cannot iterate over null (null)"}
36
+ {"id":"so-42245288","request":"Append a new message object to the messages array within the data object of the input JSON.","command":"jq '.data.messages += [{\"date\": \"2010-01-07T19:55:99.999Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"OKKK\", \"message\": \"metadata loaded into iRODS successfullyyyyy\"}]'","input_text":"{\"report\": \"1.0\", \"data\": {\"date\": \"2010-01-07\", \"messages\": [{\"date\": \"2010-01-07T19:58:42.949Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"OK\", \"message\": \"metadata loaded into iRODS successfully\"}, {\"date\": \"2010-01-07T20:22:46.949Z\", \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\", \"status\": \"NOK\", \"message\": \"metadata duplicated into iRODS\"}]}}","expected_output":"{\n \"report\": \"1.0\",\n \"data\": {\n \"date\": \"2010-01-07\",\n \"messages\": [\n {\n \"date\": \"2010-01-07T19:58:42.949Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OK\",\n \"message\": \"metadata loaded into iRODS successfully\"\n },\n {\n \"date\": \"2010-01-07T20:22:46.949Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"NOK\",\n \"message\": \"metadata duplicated into iRODS\"\n },\n {\n \"date\": \"2010-01-07T19:55:99.999Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OKKK\",\n \"message\": \"metadata loaded into iRODS successfullyyyyy\"\n }\n ]\n }\n}\n","validation_input":"{\"report\": \"2.0\", \"data\": {\"date\": \"2011-01-07\", \"messages\": [{\"date\": \"2011-01-07T10:00:00.000Z\", \"xml\": \"test.xml\", \"status\": \"OK\", \"message\": \"test msg\"}]}}","validation_output":"{\n \"report\": \"2.0\",\n \"data\": {\n \"date\": \"2011-01-07\",\n \"messages\": [\n {\n \"date\": \"2011-01-07T10:00:00.000Z\",\n \"xml\": \"test.xml\",\n \"status\": \"OK\",\n \"message\": \"test msg\"\n },\n {\n \"date\": \"2010-01-07T19:55:99.999Z\",\n \"xml\": \"xml_samplesheet_2017_01_07_run_09.xml\",\n \"status\": \"OKKK\",\n \"message\": \"metadata loaded into iRODS successfullyyyyy\"\n }\n ]\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42245288/add-new-element-to-existing-json-array-with-jq","question_title":"Add new element to existing JSON array with jq","question_owner":"Felipe","answer_owner":"Inian","answer_id":42248841,"question_score":133,"reviewed":true,"prediction":"jq '.data.messages + [{date: .data.date, xml: .data.messages[-1].xml, status: .data.messages[-1].status, message: .data.messages[-1].message}]'","valid":true,"correct":false,"error":null}
37
+ {"id":"so-42427725","request":"Convert an array of objects with 'name' and 'value' fields into a single object where each key is the 'name' value and the corresponding value is the original object.","command":"jq 'map({(.name): .}) | add'","input_text":"[\n {\"name\": \"A\", \"value\": \"1\"},\n {\"name\": \"B\", \"value\": \"5\"},\n {\"name\": \"E\", \"value\": \"8\"}\n]","expected_output":"{\n \"A\": {\n \"name\": \"A\",\n \"value\": \"1\"\n },\n \"B\": {\n \"name\": \"B\",\n \"value\": \"5\"\n },\n \"E\": {\n \"name\": \"E\",\n \"value\": \"8\"\n }\n}\n","validation_input":"[\n {\"name\": \"X\", \"value\": \"10\"},\n {\"name\": \"Y\", \"value\": \"20\"}\n]","validation_output":"{\n \"X\": {\n \"name\": \"X\",\n \"value\": \"10\"\n },\n \"Y\": {\n \"name\": \"Y\",\n \"value\": \"20\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42427725/using-jq-convert-array-of-objects-to-object-with-named-keys","question_title":"Using jq, convert array of objects to object with named keys","question_owner":"Mike N","answer_owner":"peak","answer_id":42428341,"question_score":62,"reviewed":true,"prediction":"jq '.[] | {name: .value, value: .name}'","valid":true,"correct":false,"error":null}
38
+ {"id":"so-42746828","request":"Filter objects in a JSON array to keep only those where none of the strings in the \"imageTags\" array contain the text \"latest\".","command":"jq '[.[] | select([.imageTags[] | contains(\"latest\")] | any | not)]'","input_text":"[\n {\n \"imagePushedAt\": 100,\n \"imageTags\": [\"v1\", \"stable\"]\n },\n {\n \"imagePushedAt\": 200,\n \"imageTags\": [\"v2\", \"latest\"]\n },\n {\n \"imagePushedAt\": 300,\n \"imageTags\": [\"v3\"]\n }\n]","expected_output":"[\n {\n \"imagePushedAt\": 100,\n \"imageTags\": [\n \"v1\",\n \"stable\"\n ]\n },\n {\n \"imagePushedAt\": 300,\n \"imageTags\": [\n \"v3\"\n ]\n }\n]\n","validation_input":"[\n {\n \"imagePushedAt\": 400,\n \"imageTags\": [\"release-candidate\"]\n },\n {\n \"imagePushedAt\": 500,\n \"imageTags\": [\"latest-build\"]\n },\n {\n \"imagePushedAt\": 600,\n \"imageTags\": []\n }\n]","validation_output":"[\n {\n \"imagePushedAt\": 400,\n \"imageTags\": [\n \"release-candidate\"\n ]\n },\n {\n \"imagePushedAt\": 600,\n \"imageTags\": []\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/42746828/jq-how-to-query-for-array-values-that-dont-contain-text-foo","question_title":"jq: how to query for array values that don&#39;t contain text &quot;foo&quot;?","question_owner":"Gavriel Fishel","answer_owner":"J. Doe","answer_id":42747910,"question_score":92,"reviewed":true,"prediction":"jq '[.[] | select(not any(.imageTags | contains(\"latest\")))]'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected IDENT, expecting ';' or ')' (Unix shell quoting issues?) at <top-level>, line 1:\n[.[] | select(not any(.imageTags | contains(\"latest\")))] \njq: 1 compile error"}
39
+ {"id":"so-43221453","request":"Group an array of objects by their 'component' field and output separate objects for each component, where the key is the component name and the value is an array of the associated 'ip' addresses.","command":"jq 'group_by(.component)[] | {(.[0].component): [.[] | .ip]}'","input_text":"[\n {\"ip\": \"1.1.1.1\", \"component\": \"name1\"},\n {\"ip\": \"1.1.1.2\", \"component\": \"name1\"},\n {\"ip\": \"1.1.1.3\", \"component\": \"name2\"},\n {\"ip\": \"1.1.1.4\", \"component\": \"name2\"}\n]","expected_output":"{\n \"name1\": [\n \"1.1.1.1\",\n \"1.1.1.2\"\n ]\n}\n{\n \"name2\": [\n \"1.1.1.3\",\n \"1.1.1.4\"\n ]\n}\n","validation_input":"[\n {\"ip\": \"2.2.2.1\", \"component\": \"web\"},\n {\"ip\": \"2.2.2.2\", \"component\": \"db\"},\n {\"ip\": \"2.2.2.3\", \"component\": \"web\"}\n]","validation_output":"{\n \"db\": [\n \"2.2.2.2\"\n ]\n}\n{\n \"web\": [\n \"2.2.2.1\",\n \"2.2.2.3\"\n ]\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43221453/jq-group-and-key-by-property","question_title":"jq: group and key by property","question_owner":"replay","answer_owner":"replay","answer_id":43221520,"question_score":57,"reviewed":true,"prediction":"jq 'group_by(.component) | map({component: .[0].component, ip: .[0].ip})'","valid":true,"correct":false,"error":null}
40
+ {"id":"so-43291389","request":"Extract the absoluteNumber, airedEpisodeNumber, episodeName, and overview from each object in the data array, joining them with a pipe delimiter per line.","command":"jq -r '.data[] | [.absoluteNumber, .airedEpisodeNumber, .episodeName, .overview] | join(\"|\")'","input_text":"{\"data\": [{\"absoluteNumber\": 51, \"airedEpisodeNumber\": 6, \"episodeName\": \"We Will Rise\", \"overview\": \"Clarke and Roan must work together.\"}]}","expected_output":"51|6|We Will Rise|Clarke and Roan must work together.\n","validation_input":"{\"data\": [{\"absoluteNumber\": 10, \"airedEpisodeNumber\": 1, \"episodeName\": \"Pilot\", \"overview\": \"The beginning.\"}, {\"absoluteNumber\": 11, \"airedEpisodeNumber\": 2, \"episodeName\": \"Second\", \"overview\": \"Continuation.\"}]}","validation_output":"10|1|Pilot|The beginning.\n11|2|Second|Continuation.\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43291389/using-jq-to-assign-multiple-output-variables","question_title":"using jq to assign multiple output variables","question_owner":"user2328273","answer_owner":"Bertrand Martel","answer_id":43293515,"question_score":43,"reviewed":true,"prediction":"jq '.data[] | [.absoluteNumber,.airedEpisodeNumber,.episodeName,.overview] | join(\", \")'","valid":true,"correct":false,"error":null}
41
+ {"id":"so-43522133","request":"Rename the key \"veg\" to \"fruit2\" and \"worker\" to \"job\" in each object of a JSON array, removing the original keys.","command":"jq '[.[] | .[\"fruit2\"] = .veg | .[\"job\"] = .worker | del(.veg, .worker)]'","input_text":"[{\"fruit\":\"strawberry\",\"veg\":\"apple\",\"worker\":\"gardener\"}]","expected_output":"[\n {\n \"fruit\": \"strawberry\",\n \"fruit2\": \"apple\",\n \"job\": \"gardener\"\n }\n]\n","validation_input":"[{\"fruit\":\"banana\",\"veg\":\"carrot\",\"worker\":\"farmer\"}]","validation_output":"[\n {\n \"fruit\": \"banana\",\n \"fruit2\": \"carrot\",\n \"job\": \"farmer\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/43522133/using-jq-how-can-i-replace-the-name-of-a-key-with-something-else","question_title":"Using jq how can I replace the name of a key with something else","question_owner":"user486670","answer_owner":"RomanPerekhrest","answer_id":43522716,"question_score":53,"reviewed":true,"prediction":"jq '{fruit2: .[0].fruit, job: .[0].worker}'","valid":true,"correct":false,"error":null}
42
+ {"id":"so-44656515","request":"Extract the value of the 'name' field from a JSON object as raw text without surrounding quotes.","command":"jq -r '.name'","input_text":"{\"name\": \"Google\", \"id\": 1}","expected_output":"Google\n","validation_input":"{\"name\": \"Apple\", \"id\": 2}","validation_output":"Apple\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/44656515/how-to-remove-double-quotes-in-jq-output-for-parsing-json-files-in-bash","question_title":"How to remove double-quotes in jq output for parsing json files in bash?","question_owner":"Chris F","answer_owner":"Charles Duffy","answer_id":44656583,"question_score":800,"reviewed":true,"prediction":"jq '.name'","valid":true,"correct":false,"error":null}
43
+ {"id":"so-45165303","request":"For each ticket in the 'tickets' array, output a CSV line where the 'tags' array is joined into a single comma-separated string field.","command":"jq -r '.tickets[] | [.created_at, .id, .via.channel, (.tags | join(\",\"))] | @csv'","input_text":"{\n \"tickets\": [\n {\n \"created_at\": \"2016-02-02T10:00:00Z\",\n \"id\": 99999,\n \"via\": { \"channel\": \"web\" },\n \"tags\": [\"tag1\", \"tag2\", \"tag3\"]\n }\n ]\n}","expected_output":"\"2016-02-02T10:00:00Z\",99999,\"web\",\"tag1,tag2,tag3\"\n","validation_input":"{\n \"tickets\": [\n {\n \"created_at\": \"2023-01-01T00:00:00Z\",\n \"id\": 1,\n \"via\": { \"channel\": \"email\" },\n \"tags\": [\"urgent\", \"bug\"]\n },\n {\n \"created_at\": \"2023-01-02T00:00:00Z\",\n \"id\": 2,\n \"via\": { \"channel\": \"api\" },\n \"tags\": []\n }\n ]\n}","validation_output":"\"2023-01-01T00:00:00Z\",1,\"email\",\"urgent,bug\"\n\"2023-01-02T00:00:00Z\",2,\"api\",\"\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45165303/how-to-combine-an-array-into-a-single-string-value-when-using-csv-output-in-jq","question_title":"How to combine an array into a single string value when using CSV output in jq?","question_owner":"Emre Sevin&#231;","answer_owner":"zwer","answer_id":45165687,"question_score":45,"reviewed":true,"prediction":"jq -r '.tickets[] | .tags.join(\",\")'","valid":false,"correct":false,"error":"jq: error: syntax error, unexpected '(', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:\n.tickets[] | .tags.join(\",\") \njq: 1 compile error"}
44
+ {"id":"so-45523425","request":"Extract the text field from all objects in the response array, ignoring non-object entries.","command":"jq '.response[] | objects | .text'","input_text":"{\"response\": [1000, {\"id\": 1, \"text\": \"blabla\"}, {\"id\": 2, \"text\": \"hello world\"}]}","expected_output":"\"blabla\"\n\"hello world\"\n","validation_input":"{\"response\": [\"error\", {\"id\": 5, \"text\": \"first post\"}, {\"id\": 6, \"text\": \"second post\"}, null]}","validation_output":"\"first post\"\n\"second post\"\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/45523425/getting-all-the-values-of-an-array-with-jq","question_title":"getting all the values of an array with jq","question_owner":"Miss Alena","answer_owner":"peak","answer_id":45524015,"question_score":80,"reviewed":true,"prediction":"jq '.response[] | .text'","valid":false,"correct":false,"error":"jq: error (at <stdin>:0): Cannot index number with string \"text\""}
45
+ {"id":"so-46131727","request":"Extract the 'foo' and 'bar' values from the nested 'fmep' object and print them on the same line separated by a space.","command":"jq -r '.fmep | \"\\(.foo) \\(.bar)\"'","input_text":"{\n \"fmep\": {\n \"foo\": 112,\n \"bar\": 234324,\n \"cat\": 21343423\n }\n}","expected_output":"112 234324\n","validation_input":"{\n \"fmep\": {\n \"foo\": 5,\n \"bar\": 10,\n \"cat\": 15\n }\n}","validation_output":"5 10\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/46131727/printing-multiple-values-on-the-same-line","question_title":"Printing multiple values on the same line","question_owner":"Mickster","answer_owner":"jq170727","answer_id":46131963,"question_score":58,"reviewed":true,"prediction":"jq '.fmep.foo, .fmep.bar'","valid":true,"correct":false,"error":null}
46
+ {"id":"so-47023795","request":"Remove the top-level 'pages' key and its value from the JSON object, keeping all other keys intact.","command":"jq 'del(.pages)'","input_text":"{\n \"pages\": {\n \"elems\": { \"id\": 1 }\n },\n \"actions\": {\n \"pages\": { \"id\": 2 }\n }\n}","expected_output":"{\n \"actions\": {\n \"pages\": {\n \"id\": 2\n }\n }\n}\n","validation_input":"{\n \"pages\": {\n \"title\": \"Home\"\n },\n \"users\": [\n { \"name\": \"Alice\" }\n ],\n \"settings\": {\n \"theme\": \"dark\"\n }\n}","validation_output":"{\n \"users\": [\n {\n \"name\": \"Alice\"\n }\n ],\n \"settings\": {\n \"theme\": \"dark\"\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/47023795/removing-a-key-from-parent-object-with-jq","question_title":"Removing a key from parent object with jq","question_owner":"Nicholas","answer_owner":"jq170727","answer_id":47024050,"question_score":44,"reviewed":true,"prediction":"jq 'del(.pages)'","valid":true,"correct":true,"error":null}
47
+ {"id":"so-48426052","request":"Given a JSON array of user objects, extract and print the 'username' field from each object on a new line.","command":"jq -r '.[].username'","input_text":"[\n {\n \"username\": \"jdoe\",\n \"name\": \"John Doe\"\n },\n {\n \"username\": \"jadoe\",\n \"name\": \"Jane Doe\"\n }\n]","expected_output":"jdoe\njadoe\n","validation_input":"[\n {\n \"username\": \"alice\",\n \"name\": \"Alice Smith\"\n },\n {\n \"username\": \"bob\",\n \"name\": \"Bob Jones\"\n }\n]","validation_output":"alice\nbob\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/48426052/how-to-extract-a-field-from-each-object-in-an-array-with-jq","question_title":"How to extract a field from each object in an array with jq?","question_owner":"Chris F","answer_owner":"John Kugelman","answer_id":48426543,"question_score":84,"reviewed":true,"prediction":"jq '.[] | .username'","valid":true,"correct":false,"error":null}
48
+ {"id":"so-49632521","request":"Add a new key-value pair '\"operation\": \"delete\"' to the 'fields' object located at .module.data.item_i77f664a2.fields in a JSON object.","command":"jq '.module.data.item_i77f664a2.fields += {\"operation\": \"delete\"}'","input_text":"{\"success\": true, \"module\": {\"data\": {\"item_i77f664a2\": {\"id\": \"i77f664a2\", \"fields\": {\"cartItemId\": 2012636322}, \"type\": \"biz\"}}}}","expected_output":"{\n \"success\": true,\n \"module\": {\n \"data\": {\n \"item_i77f664a2\": {\n \"id\": \"i77f664a2\",\n \"fields\": {\n \"cartItemId\": 2012636322,\n \"operation\": \"delete\"\n },\n \"type\": \"biz\"\n }\n }\n }\n}\n","validation_input":"{\"success\": false, \"module\": {\"data\": {\"item_i77f664a2\": {\"id\": \"other-id\", \"fields\": {\"qty\": 5}, \"type\": \"retail\"}}}}","validation_output":"{\n \"success\": false,\n \"module\": {\n \"data\": {\n \"item_i77f664a2\": {\n \"id\": \"other-id\",\n \"fields\": {\n \"qty\": 5,\n \"operation\": \"delete\"\n },\n \"type\": \"retail\"\n }\n }\n }\n}\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/49632521/how-to-add-a-field-to-a-json-object-with-the-jq-command","question_title":"How to add a field to a JSON object with the jq command?","question_owner":"Joe","answer_owner":"peak","answer_id":49632947,"question_score":46,"reviewed":true,"prediction":"jq '.module.data.item_i77f664a2.fields + {operation: \"delete\"}'","valid":true,"correct":false,"error":null}
49
+ {"id":"so-50868203","request":"Filter a JSON array of objects to keep only those where the 'Address' field starts with a digit.","command":"jq '[.[] | select(.Address | test(\"^[0-9]\"))]'","input_text":"[{\"Address\": \"The Sq\"}, {\"Address\": \"1 Bridge Rd\"}]","expected_output":"[\n {\n \"Address\": \"1 Bridge Rd\"\n }\n]\n","validation_input":"[{\"Address\": \"No Number St\"}, {\"Address\": \"99 Main Ave\"}, {\"Address\": \"Apt 5\"}]","validation_output":"[\n {\n \"Address\": \"99 Main Ave\"\n }\n]\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/50868203/filter-by-regex-in-jq","question_title":"Filter by Regex in JQ","question_owner":"user49","answer_owner":"peak","answer_id":50868294,"question_score":48,"reviewed":true,"prediction":"jq '[.[] | select(.Address >= startswith(\"#\"))]'","valid":false,"correct":false,"error":"jq: error (at <stdin>:0): startswith() requires string inputs"}
50
+ {"id":"so-52065570","request":"Read a stream of JSON objects from stdin, extract the 'duration' field from each, and output the sum of all durations as a single number.","command":"jq -s '[.[].duration] | add'","input_text":"{\"duration\": 1211789}\n{\"duration\": 1211789}\n{\"duration\": 373585}","expected_output":"2797163\n","validation_input":"{\"duration\": 100}\n{\"duration\": 200}\n{\"duration\": 300}","validation_output":"600\n","family":"real-stackoverflow","difficulty":3,"split":"test","source":"stackoverflow-accepted-answer","license":"CC-BY-SA-4.0","question_url":"https://stackoverflow.com/questions/52065570/how-do-i-sum-all-numbers-from-output-of-jq","question_title":"How do I sum all numbers from output of jq","question_owner":"toy","answer_owner":"Charles Duffy","answer_id":52065738,"question_score":40,"reviewed":true,"prediction":"jq '.[] | .duration' | add","valid":false,"correct":false,"error":"Expected exactly one jq filter and no filenames or other options."}
evaluation/jqweave-0.5b.summary.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "asterbraid/jqweave-0.5b",
3
+ "split": "test",
4
+ "rows": 50,
5
+ "valid_at_1": 0.54,
6
+ "correct_at_1": 0.1,
7
+ "exact_output_on_two_inputs": true,
8
+ "prediction_cleanup": "special tokens only",
9
+ "seconds": 13.696113109588623,
10
+ "data_sha256": "ac913d38e7bb745944fbf4656f854ec52d85f3702dda02014b1d8b51f6c6443c",
11
+ "transformers_version": "5.17.0",
12
+ "torch_version": "2.14.0",
13
+ "families": {
14
+ "real-stackoverflow": {
15
+ "rows": 50,
16
+ "valid": 27,
17
+ "correct": 5
18
+ }
19
+ }
20
+ }
fetch_real_questions.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import time
6
+ import urllib.parse
7
+ import urllib.request
8
+ from pathlib import Path
9
+
10
+ API_ROOT = "https://api.stackexchange.com/2.3"
11
+
12
+
13
+ def get_json(path: str, **params) -> dict:
14
+ query = urllib.parse.urlencode({"site": "stackoverflow", "filter": "withbody", **params})
15
+ request = urllib.request.Request(
16
+ f"{API_ROOT}/{path}?{query}",
17
+ headers={"User-Agent": "Asterbraid-Jqweave-Dataset/1.0"},
18
+ )
19
+ with urllib.request.urlopen(request, timeout=60) as response:
20
+ data = json.load(response)
21
+ if "error_message" in data:
22
+ raise RuntimeError(data["error_message"])
23
+ if data.get("backoff"):
24
+ time.sleep(data["backoff"])
25
+ return data
26
+
27
+
28
+ def main() -> None:
29
+ parser = argparse.ArgumentParser()
30
+ parser.add_argument("--output-dir", type=Path, default=Path(".tmp"))
31
+ parser.add_argument("--pages", type=int, default=1)
32
+ args = parser.parse_args()
33
+ args.output_dir.mkdir(parents=True, exist_ok=True)
34
+
35
+ questions = []
36
+ for page in range(1, args.pages + 1):
37
+ data = get_json("questions", order="desc", sort="votes", tagged="jq", pagesize=100, page=page)
38
+ questions.extend(data["items"])
39
+ if not data.get("has_more"):
40
+ break
41
+ (args.output_dir / "jq-questions.json").write_text(json.dumps({"items": questions}, indent=2), encoding="utf-8")
42
+
43
+ answer_ids = [str(question["accepted_answer_id"]) for question in questions if "accepted_answer_id" in question]
44
+ answers = {}
45
+ for start in range(0, len(answer_ids), 100):
46
+ batch = answer_ids[start:start + 100]
47
+ data = get_json("answers/" + ";".join(batch), order="desc", sort="activity", pagesize=100)
48
+ for answer in data["items"]:
49
+ answers[str(answer["answer_id"])] = answer
50
+ (args.output_dir / "jq-answers.json").write_text(json.dumps(answers, indent=2), encoding="utf-8")
51
+ print(f"saved {len(questions)} questions and {len(answers)} accepted answers")
52
+
53
+
54
+ if __name__ == "__main__":
55
+ main()
jqweave/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Jqweave natural-language-to-jq tools."""
jqweave/execution.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ import resource
5
+ import shlex
6
+ import shutil
7
+ import subprocess
8
+ from pathlib import Path
9
+
10
+ MAX_INPUT_BYTES = 1_000_000
11
+ MAX_COMMAND_CHARS = 4_000
12
+ ENV_PATTERN = re.compile(r"\$ENV\b|(?<![A-Za-z0-9_.])env(?![A-Za-z0-9_])")
13
+ MODULE_PATTERN = re.compile(r"(?<![A-Za-z0-9_.])(?:import|include|load|modulemeta)(?![A-Za-z0-9_])")
14
+ INPUT_PATTERN = re.compile(r"(?<![A-Za-z0-9_.])inputs?(?![A-Za-z0-9_])")
15
+
16
+
17
+ class UnsafeCommandError(ValueError):
18
+ pass
19
+
20
+
21
+ def check_command(command: str) -> list[str]:
22
+ if not command.strip():
23
+ raise UnsafeCommandError("The jq command is empty.")
24
+ if len(command) > MAX_COMMAND_CHARS:
25
+ raise UnsafeCommandError("The jq command is too long.")
26
+ try:
27
+ arguments = shlex.split(command)
28
+ except ValueError as error:
29
+ raise UnsafeCommandError(f"Cannot parse jq command: {error}") from error
30
+ if not arguments or arguments[0] != "jq":
31
+ raise UnsafeCommandError("Only jq commands are allowed.")
32
+ if ENV_PATTERN.search(command) or MODULE_PATTERN.search(command) or INPUT_PATTERN.search(command):
33
+ raise UnsafeCommandError("Environment, module, and additional-input access are not allowed.")
34
+ index = 1
35
+ options = []
36
+ while index < len(arguments) and arguments[index] in {"-c", "-r", "-s"}:
37
+ options.append(arguments[index])
38
+ index += 1
39
+ if len(options) > 1:
40
+ raise UnsafeCommandError("Use at most one jq option.")
41
+ if index != len(arguments) - 1:
42
+ raise UnsafeCommandError("Expected exactly one jq filter and no filenames or other options.")
43
+ return arguments
44
+
45
+
46
+ def limit_resources() -> None:
47
+ resource.setrlimit(resource.RLIMIT_CPU, (2, 2))
48
+ resource.setrlimit(resource.RLIMIT_AS, (256_000_000, 256_000_000))
49
+ resource.setrlimit(resource.RLIMIT_FSIZE, (1_000_000, 1_000_000))
50
+ resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
51
+ resource.setrlimit(resource.RLIMIT_NOFILE, (16, 16))
52
+
53
+
54
+ def run_jq(command: str, input_text: str, timeout: float = 3.0) -> str:
55
+ arguments = check_command(command)
56
+ if len(input_text.encode("utf-8")) > MAX_INPUT_BYTES:
57
+ raise ValueError("Input text exceeds the 1 MB limit.")
58
+ executable = shutil.which("jq")
59
+ if executable is None:
60
+ bundled = Path(__file__).parent / "bin" / "jq"
61
+ if bundled.is_file():
62
+ runnable = Path("/tmp/jqweave-jq")
63
+ if not runnable.exists():
64
+ shutil.copyfile(bundled, runnable)
65
+ runnable.chmod(0o755)
66
+ executable = str(runnable)
67
+ if executable is None:
68
+ raise RuntimeError("No jq executable is available on PATH or in the bundled runtime.")
69
+ result = subprocess.run(
70
+ [executable, *arguments[1:]],
71
+ input=input_text,
72
+ text=True,
73
+ capture_output=True,
74
+ timeout=timeout,
75
+ env={"LC_ALL": "C", "PATH": "/usr/bin:/bin"},
76
+ preexec_fn=limit_resources,
77
+ start_new_session=True,
78
+ check=False,
79
+ )
80
+ if result.returncode != 0:
81
+ raise ValueError(result.stderr.strip() or f"jq exited with status {result.returncode}")
82
+ return result.stdout
review_so.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ from jqweave.execution import run_jq
7
+
8
+ INPUT = Path("jqweave-so.jsonl")
9
+ OUTPUT = Path("jqweave-so-reviewed.jsonl")
10
+ COMMAND_FIXES = {
11
+ "so-26701538": "jq -r '.[] | select(.Names | all(contains(\"data\") | not)) | .Id'",
12
+ }
13
+ INPUT_FIXES = {
14
+ "so-26701538": "[{\"Id\": \"123\", \"Names\": [\"jovial_wozniak\"]}, {\"Id\": \"456\", \"Names\": [\"bar_data\"]}, {\"Id\": \"mix\", \"Names\": [\"foo_data\", \"safe\"]}]",
15
+ }
16
+
17
+ rows = [json.loads(line) for line in INPUT.open(encoding="utf-8")]
18
+ with OUTPUT.open("w", encoding="utf-8") as handle:
19
+ for row in rows:
20
+ row["command"] = COMMAND_FIXES.get(row["id"], row["command"])
21
+ row["validation_input"] = INPUT_FIXES.get(row["id"], row["validation_input"])
22
+ row["expected_output"] = run_jq(row["command"], row["input_text"])
23
+ row["validation_output"] = run_jq(row["command"], row["validation_input"])
24
+ row["reviewed"] = True
25
+ handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n")
26
+ print(f"reviewed {len(rows)} rows")
validate_dataset.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import collections
5
+ import concurrent.futures
6
+ import hashlib
7
+ import json
8
+ import subprocess
9
+ from pathlib import Path
10
+
11
+ from jqweave.execution import run_jq
12
+
13
+
14
+ def jq_version() -> str:
15
+ result = subprocess.run(["jq", "--version"], capture_output=True, text=True, check=False)
16
+ return (result.stdout or result.stderr).strip()
17
+
18
+
19
+ def validate_row(row: dict) -> tuple[str, str | None]:
20
+ try:
21
+ if run_jq(row["command"], row["input_text"]) != row["expected_output"]:
22
+ return row["id"], "primary output mismatch"
23
+ if run_jq(row["command"], row["validation_input"]) != row["validation_output"]:
24
+ return row["id"], "validation output mismatch"
25
+ return row["id"], None
26
+ except Exception as error:
27
+ return row["id"], str(error)[:500]
28
+
29
+
30
+ def main() -> None:
31
+ parser = argparse.ArgumentParser()
32
+ parser.add_argument("data", type=Path)
33
+ parser.add_argument("--workers", type=int, default=8)
34
+ parser.add_argument("--output", type=Path)
35
+ args = parser.parse_args()
36
+ rows = [json.loads(line) for line in args.data.open(encoding="utf-8")]
37
+ ids = [row["id"] for row in rows]
38
+ if len(ids) != len(set(ids)):
39
+ raise ValueError("Duplicate row IDs")
40
+ errors = []
41
+ with concurrent.futures.ProcessPoolExecutor(max_workers=args.workers) as executor:
42
+ for completed, (row_id, error) in enumerate(executor.map(validate_row, rows, chunksize=100), 1):
43
+ if error:
44
+ errors.append({"id": row_id, "error": error})
45
+ if completed % 5000 == 0:
46
+ print(f"validated {completed}/{len(rows)}", flush=True)
47
+ split_integrity = {}
48
+ for left, right in (("train", "validation"), ("train", "test"), ("validation", "test")):
49
+ left_rows = [row for row in rows if row["split"] == left]
50
+ right_rows = [row for row in rows if row["split"] == right]
51
+ split_integrity[f"{left}-{right}"] = {
52
+ "input_overlap": len({row["input_text"] for row in left_rows} & {row["input_text"] for row in right_rows}),
53
+ "request_command_overlap": len(
54
+ {(row["request"], row["command"]) for row in left_rows}
55
+ & {(row["request"], row["command"]) for row in right_rows}
56
+ ),
57
+ }
58
+ summary = {
59
+ "data": str(args.data),
60
+ "sha256": hashlib.sha256(args.data.read_bytes()).hexdigest(),
61
+ "rows": len(rows),
62
+ "executions": len(rows) * 2,
63
+ "jq_version": jq_version(),
64
+ "errors": errors,
65
+ "splits": dict(collections.Counter(row["split"] for row in rows)),
66
+ "sources": dict(collections.Counter(row["source"] for row in rows)),
67
+ "families": dict(collections.Counter(row["family"] for row in rows)),
68
+ "unique_requests": len({row["request"] for row in rows}),
69
+ "unique_commands": len({row["command"] for row in rows}),
70
+ "split_integrity": split_integrity,
71
+ }
72
+ text = json.dumps(summary, indent=2)
73
+ if args.output:
74
+ args.output.write_text(text, encoding="utf-8")
75
+ print(text)
76
+ if errors:
77
+ raise SystemExit(1)
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
validation.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "data": "jqweave-so.jsonl",
3
+ "sha256": "ac913d38e7bb745944fbf4656f854ec52d85f3702dda02014b1d8b51f6c6443c",
4
+ "rows": 50,
5
+ "executions": 100,
6
+ "jq_version": "jq-1.6",
7
+ "errors": [],
8
+ "splits": {
9
+ "test": 50
10
+ },
11
+ "sources": {
12
+ "stackoverflow-accepted-answer": 50
13
+ },
14
+ "families": {
15
+ "real-stackoverflow": 50
16
+ },
17
+ "unique_requests": 50,
18
+ "unique_commands": 49,
19
+ "split_integrity": {
20
+ "train-validation": {
21
+ "input_overlap": 0,
22
+ "request_command_overlap": 0
23
+ },
24
+ "train-test": {
25
+ "input_overlap": 0,
26
+ "request_command_overlap": 0
27
+ },
28
+ "validation-test": {
29
+ "input_overlap": 0,
30
+ "request_command_overlap": 0
31
+ }
32
+ },
33
+ "seed_split_integrity": {
34
+ "input_overlap": 0,
35
+ "request_command_overlap": 0
36
+ }
37
+ }