PageSourceSearch

https://jqlang.org/tutorial/

html jqlang.org collected 2026-09-24 08:26:33 UTC 24,976 bytes, 419 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en">
3  <head>
4    <meta charset="utf-8">
5    <title>Tutorial</title>
6    <meta name="viewport" content="width=device-width, initial-scale=1">
7    <meta property="og:title" content="Tutorial">
8    <meta property="og:description" content="jq is a lightweight and flexible command-line JSON processor">
9    <meta property="og:type" content="website">
10    <meta property="og:image" content="https://jqlang.org/icon.png">
11    <meta property="og:url" content="https://jqlang.org/tutorial/">
12    <link rel="icon" href="/icon.svg" type="image/svg+xml">
13    <link rel="apple-touch-icon" href="/icon.png" type="image/png">
14    <link rel="canonical" href="https://jqlang.org/tutorial/">
15    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/cosmo/bootstrap.min.css"
16      integrity="sha384-dulfW0vmzZ638jigSgZXvDxMmd70GCnIv6oa+riKq6Kk4E0MKf7qmBfwP02wltv5" crossorigin="anonymous">
17    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
18      integrity="sha384-Ay26V7L8bsJTsX9Sxclnvsn+hkdiwRnrjZJXqKmkIDobPgIIWBOVguEcQQLDuhfN" crossorigin="anonymous">
19    <link rel="stylesheet" href="/css/style.css" type="text/css">
20    
20<script>
21      (function() {
22        function setTheme(mediaQuery) {
23          document.documentElement.setAttribute('data-bs-theme',
24            document.documentElement.style.colorScheme = mediaQuery.matches ? 'dark' : 'light');
25        }
26        const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
27        setTheme(mediaQuery); mediaQuery.addEventListener('change', setTheme);
28      })();
29    </script>
29
30  </head>
31
32  <body>
33    <div class="container visually-hidden-focusable">
34      <a class="d-inline-flex p-2" href="#main">Skip to main content</a>
35    </div>
36    <header class="navbar navbar-expand-md sticky-top bg-body-tertiary d-print-none">
37      <nav class="container-lg" aria-label="Page navigation">
38        <button type="button" class="navbar-toggler" data-bs-toggle="offcanvas" data-bs-target="#navbar-collapse"
39          aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle page navigation">
40          <span class="navbar-toggler-icon"></span>
41        </button>
42        <a class="navbar-brand" href="/" aria-label="Top page"><img src="/jq.svg" alt="jq logo" style="height:1.5rem"></a>
43        <div id="navbar-collapse" class="offcanvas offcanvas-start navbar-collapse w-auto" aria-labelledby="navbar-title">
44          <div class="offcanvas-header">
45            <h3 id="navbar-title" class="me-3">jq</h3>
46            <button type="button" class="d-md-none btn-close" data-bs-dismiss="offcanvas" aria-label="Close page navigation"></button>
47          </div>
48          <ul class="offcanvas-body navbar-nav me-auto text-nowrap">
49            <li class="nav-item d-md-none"><a class="nav-link" href="/">Top page</a></li>
50            <li class="nav-item"><a class="nav-link active" aria-current="page" href="/tutorial/">Tutorial</a></li>
51            <li class="nav-item"><a class="nav-link" href="/download/">Download</a></li>
52            <li class="nav-item"><a class="nav-link" href="/manual/">Manual</a></li>
53            <li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq" target="_blank" rel="noopener">GitHub</a></li>
54            <li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/issues" target="_blank" rel="noopener">Issues</a></li>
55            <li class="nav-item"><a class="nav-link" href="https://play.jqlang.org" rel="noopener">Try online!</a></li>
56            <li class="nav-item"><a class="nav-link" href="https://raw.githubusercontent.com/jqlang/jq/master/NEWS.md" target="_blank" rel="noopener">News</a></li>
57            <li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/wiki" target="_blank" rel="noopener">Wiki</a></li>
58          </ul>
59        </div>
60        <a class="d-md-none bi bi-github fs-4 text-body" href="https://github.com/jqlang/jq" target="_blank" rel="noopener" aria-label="GitHub"></a>
61      </nav>
62    </header>
63
64    <main id="main" class="container-lg">
65      <h1>Tutorial</h1>
66      <p>GitHub has a JSON API, so let's play with that. This URL gets us the last
675 commits from the jq repo.</p>
68      <div class="tutorial-example mb-3">
69        <div class="d-flex accordion-heading me-2">
70          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">curl &#39;https://api.github.com/repos/jqlang/jq/commits?per_page=5&#39;</pre>
71          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
72            data-bs-toggle="collapse" data-bs-target="#result1" aria-expanded="false" aria-controls="result1"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
73        </div>
74        <pre id="result1" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">[
75  {
76    &#34;sha&#34;: &#34;cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
77    &#34;node_id&#34;: &#34;C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg&#34;,
78    &#34;commit&#34;: {
79      &#34;author&#34;: {
80        &#34;name&#34;: &#34;Mattias Wadman&#34;,
81        &#34;email&#34;: &#34;[email protected]&#34;,
82        &#34;date&#34;: &#34;2021-06-09T14:02:22Z&#34;
83      },
84      &#34;committer&#34;: {
85        &#34;name&#34;: &#34;Nico Williams&#34;,
86        &#34;email&#34;: &#34;[email protected]&#34;,
87        &#34;date&#34;: &#34;2022-05-26T21:04:32Z&#34;
88      },
89      &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
90      &#34;tree&#34;: {
91        &#34;sha&#34;: &#34;d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;,
92        &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;
93      },
94      &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
95      &#34;comment_count&#34;: 0,
96      &#34;verification&#34;: {
97        &#34;verified&#34;: false,
98        &#34;reason&#34;: &#34;unsigned&#34;,
99        &#34;signature&#34;: null,
100        &#34;payload&#34;: null
101      }
102    },
103    &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
104    &#34;html_url&#34;: &#34;https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
105    &#34;comments_url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments&#34;,
106    &#34;author&#34;: {
107...
108</pre>
109      </div>
110      <p>GitHub returns nicely formatted JSON. For servers that don't, it can be
111helpful to pipe the response through jq to pretty-print it. The simplest
112jq program is the expression <code>.</code>, which takes the input and produces it
113unchanged as output.</p>
114      <div class="tutorial-example mb-3">
115        <div class="d-flex accordion-heading me-2">
116          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">curl &#39;https://api.github.com/repos/jqlang/jq/commits?per_page=5&#39; | jq &#39;.&#39;</pre>
117          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
118            data-bs-toggle="collapse" data-bs-target="#result2" aria-expanded="false" aria-controls="result2"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
119        </div>
120        <pre id="result2" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">[
121  {
122    &#34;sha&#34;: &#34;cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
123    &#34;node_id&#34;: &#34;C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg&#34;,
124    &#34;commit&#34;: {
125      &#34;author&#34;: {
126        &#34;name&#34;: &#34;Mattias Wadman&#34;,
127        &#34;email&#34;: &#34;[email protected]&#34;,
128        &#34;date&#34;: &#34;2021-06-09T14:02:22Z&#34;
129      },
130      &#34;committer&#34;: {
131        &#34;name&#34;: &#34;Nico Williams&#34;,
132        &#34;email&#34;: &#34;[email protected]&#34;,
133        &#34;date&#34;: &#34;2022-05-26T21:04:32Z&#34;
134      },
135      &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
136      &#34;tree&#34;: {
137        &#34;sha&#34;: &#34;d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;,
138        &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;
139      },
140      &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
141      &#34;comment_count&#34;: 0,
142      &#34;verification&#34;: {
143        &#34;verified&#34;: false,
144        &#34;reason&#34;: &#34;unsigned&#34;,
145        &#34;signature&#34;: null,
146        &#34;payload&#34;: null
147      }
148    },
149    &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
150    &#34;html_url&#34;: &#34;https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
151    &#34;comments_url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments&#34;,
152    &#34;author&#34;: {
153...
154</pre>
155      </div>
156      <p>We can use jq to extract just the first commit.</p>
157      <div class="tutorial-example mb-3">
158        <div class="d-flex accordion-heading me-2">
159          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">curl &#39;https://api.github.com/repos/jqlang/jq/commits?per_page=5&#39; | jq &#39;.[0]&#39;</pre>
160          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
161            data-bs-toggle="collapse" data-bs-target="#result3" aria-expanded="false" aria-controls="result3"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
162        </div>
163        <pre id="result3" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">{
164  &#34;sha&#34;: &#34;cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
165  &#34;node_id&#34;: &#34;C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg&#34;,
166  &#34;commit&#34;: {
167    &#34;author&#34;: {
168      &#34;name&#34;: &#34;Mattias Wadman&#34;,
169      &#34;email&#34;: &#34;[email protected]&#34;,
170      &#34;date&#34;: &#34;2021-06-09T14:02:22Z&#34;
171    },
172    &#34;committer&#34;: {
173      &#34;name&#34;: &#34;Nico Williams&#34;,
174      &#34;email&#34;: &#34;[email protected]&#34;,
175      &#34;date&#34;: &#34;2022-05-26T21:04:32Z&#34;
176    },
177    &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
178    &#34;tree&#34;: {
179      &#34;sha&#34;: &#34;d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;,
180      &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b&#34;
181    },
182    &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
183    &#34;comment_count&#34;: 0,
184    &#34;verification&#34;: {
185      &#34;verified&#34;: false,
186      &#34;reason&#34;: &#34;unsigned&#34;,
187      &#34;signature&#34;: null,
188      &#34;payload&#34;: null
189    }
190  },
191  &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
192  &#34;html_url&#34;: &#34;https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8&#34;,
193  &#34;comments_url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments&#34;,
194  &#34;author&#34;: {
195    &#34;login&#34;: &#34;wader&#34;,
196    &#34;id&#34;: 185566,
197    &#34;node_id&#34;: &#34;MDQ6VXNlcjE4NTU2Ng==&#34;,
198    &#34;avatar_url&#34;: &#34;https://avatars.githubusercontent.com/u/185566?v=4&#34;,
199    &#34;gravatar_id&#34;: &#34;&#34;,
200    &#34;url&#34;: &#34;https://api.github.com/users/wader&#34;,
201    &#34;html_url&#34;: &#34;https://github.com/wader&#34;,
202    &#34;followers_url&#34;: &#34;https://api.github.com/users/wader/followers&#34;,
203    &#34;following_url&#34;: &#34;https://api.github.com/users/wader/following{/other_user}&#34;,
204    &#34;gists_url&#34;: &#34;https://api.github.com/users/wader/gists{/gist_id}&#34;,
205    &#34;starred_url&#34;: &#34;https://api.github.com/users/wader/starred{/owner}{/repo}&#34;,
206    &#34;subscriptions_url&#34;: &#34;https://api.github.com/users/wader/subscriptions&#34;,
207    &#34;organizations_url&#34;: &#34;https://api.github.com/users/wader/orgs&#34;,
208    &#34;repos_url&#34;: &#34;https://api.github.com/users/wader/repos&#34;,
209    &#34;events_url&#34;: &#34;https://api.github.com/users/wader/events{/privacy}&#34;,
210    &#34;received_events_url&#34;: &#34;https://api.github.com/users/wader/received_events&#34;,
211    &#34;type&#34;: &#34;User&#34;,
212    &#34;site_admin&#34;: false
213  },
214  &#34;committer&#34;: {
215    &#34;login&#34;: &#34;nicowilliams&#34;,
216    &#34;id&#34;: 604851,
217    &#34;node_id&#34;: &#34;MDQ6VXNlcjYwNDg1MQ==&#34;,
218    &#34;avatar_url&#34;: &#34;https://avatars.githubusercontent.com/u/604851?v=4&#34;,
219    &#34;gravatar_id&#34;: &#34;&#34;,
220    &#34;url&#34;: &#34;https://api.github.com/users/nicowilliams&#34;,
221    &#34;html_url&#34;: &#34;https://github.com/nicowilliams&#34;,
222    &#34;followers_url&#34;: &#34;https://api.github.com/users/nicowilliams/followers&#34;,
223    &#34;following_url&#34;: &#34;https://api.github.com/users/nicowilliams/following{/other_user}&#34;,
224    &#34;gists_url&#34;: &#34;https://api.github.com/users/nicowilliams/gists{/gist_id}&#34;,
225    &#34;starred_url&#34;: &#34;https://api.github.com/users/nicowilliams/starred{/owner}{/repo}&#34;,
226    &#34;subscriptions_url&#34;: &#34;https://api.github.com/users/nicowilliams/subscriptions&#34;,
227    &#34;organizations_url&#34;: &#34;https://api.github.com/users/nicowilliams/orgs&#34;,
228    &#34;repos_url&#34;: &#34;https://api.github.com/users/nicowilliams/repos&#34;,
229    &#34;events_url&#34;: &#34;https://api.github.com/users/nicowilliams/events{/privacy}&#34;,
230    &#34;received_events_url&#34;: &#34;https://api.github.com/users/nicowilliams/received_events&#34;,
231    &#34;type&#34;: &#34;User&#34;,
232    &#34;site_admin&#34;: false
233  },
234  &#34;parents&#34;: [
235    {
236      &#34;sha&#34;: &#34;
236f2ad9517c72f6267ae317639ab56bbfd4a8653d4&#34;,
237      &#34;url&#34;: &#34;https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4&#34;,
238      &#34;html_url&#34;: &#34;https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4&#34;
239    }
240  ]
241}
242</pre>
243      </div>
244      <p>For the rest of the examples, I'll leave out the <code>curl</code> command - it's not
245going to change.</p>
246<p>There's a lot of info we don't care about there, so we'll restrict it down
247to the most interesting fields.</p>
248      <div class="tutorial-example mb-3">
249        <div class="d-flex accordion-heading me-2">
250          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">jq &#39;.[0] | {message: .commit.message, name: .commit.committer.name}&#39;</pre>
251          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
252            data-bs-toggle="collapse" data-bs-target="#result4" aria-expanded="false" aria-controls="result4"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
253        </div>
254        <pre id="result4" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">{
255  &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
256  &#34;name&#34;: &#34;Nico Williams&#34;
257}
258</pre>
259      </div>
260      <p>The <code>|</code> operator in jq feeds the output of one filter (<code>.[0]</code> which gets
261the first element of the array in the response) into the input of another
262(<code>{...}</code> which builds an object out of those fields). You can access
263nested attributes, such as <code>.commit.message</code>.</p>
264<p>Now let's get the rest of the commits.</p>
265      <div class="tutorial-example mb-3">
266        <div class="d-flex accordion-heading me-2">
267          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">jq &#39;.[] | {message: .commit.message, name: .commit.committer.name}&#39;</pre>
268          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
269            data-bs-toggle="collapse" data-bs-target="#result5" aria-expanded="false" aria-controls="result5"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
270        </div>
271        <pre id="result5" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">{
272  &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
273  &#34;name&#34;: &#34;Nico Williams&#34;
274}
275{
276  &#34;message&#34;: &#34;Mention -n in IO-section and for input/inputs&#34;,
277  &#34;name&#34;: &#34;Nico Williams&#34;
278}
279{
280  &#34;message&#34;: &#34;Fix iteration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happened because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.&#34;,
281  &#34;name&#34;: &#34;Nico Williams&#34;
282}
283{
284  &#34;message&#34;: &#34;docs: point to Libera.Chat instead of Freenode&#34;,
285  &#34;name&#34;: &#34;Nico Williams&#34;
286}
287{
288  &#34;message&#34;: &#34;Missing \&#34;va_end\&#34; call. This was found by running the cppcheck static analysis where it shows as error.&#34;,
289  &#34;name&#34;: &#34;Nico Williams&#34;
290}
291</pre>
292      </div>
293      <p><code>.[]</code> returns each element of the array returned in the response, one at a
294time, which are all fed into
295<code>{message: .commit.message, name: .commit.committer.name}</code>.</p>
296<p>Data in jq is represented as streams of JSON values - every jq
297expression runs for each value in its input stream, and can
298produce any number of values to its output stream.</p>
299<p>Streams are serialised by just separating JSON values with
300whitespace. This is a <code>cat</code>-friendly format - you can just join
301two JSON streams together and get a valid JSON stream.</p>
302<p>If you want to get the output as a single array, you can tell jq to
303"collect" all of the answers by wrapping the filter in square
304brackets:</p>
305      <div class="tutorial-example mb-3">
306        <div class="d-flex accordion-heading me-2">
307          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">jq &#39;[.[] | {message: .commit.message, name: .commit.committer.name}]&#39;</pre>
308          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
309            data-bs-toggle="collapse" data-bs-target="#result6" aria-expanded="false" aria-controls="result6"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
310        </div>
311        <pre id="result6" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">[
312  {
313    &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
314    &#34;name&#34;: &#34;Nico Williams&#34;
315  },
316  {
317    &#34;message&#34;: &#34;Mention -n in IO-section and for input/inputs&#34;,
318    &#34;name&#34;: &#34;Nico Williams&#34;
319  },
320  {
321    &#34;message&#34;: &#34;Fix iteration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happened because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.&#34;,
322    &#34;name&#34;: &#34;Nico Williams&#34;
323  },
324  {
325    &#34;message&#34;: &#34;docs: point to Libera.Chat instead of Freenode&#34;,
326    &#34;name&#34;: &#34;Nico Williams&#34;
327  },
328  {
329    &#34;message&#34;: &#34;Missing \&#34;va_end\&#34; call. This was found by running the cppcheck static analysis where it shows as error.&#34;,
330    &#34;name&#34;: &#34;Nico Williams&#34;
331  }
332]
333</pre>
334      </div>
335      <hr />
336<p>Next, let's try getting the URLs of the parent commits out of the
337API results as well. In each commit, the GitHub API includes information
338about "parent" commits. There can be one or many.</p>
339<pre><code>"parents": [
340  {
341    "sha": "f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
342    "url": "https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4",
343    "html_url": "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4"
344  }
345]
346</code></pre>
347<p>We want to pull out all of the "html_url" fields inside that array of parent
348commits and make a simple list of strings to go along with the
349"message" and "author" fields we already have.</p>
350      <div class="tutorial-example mb-3">
351        <div class="d-flex accordion-heading me-2">
352          <pre class="flex-grow-1 me-0 mb-0" tabindex="0">jq &#39;[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]&#39;</pre>
353          <button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
354            data-bs-toggle="collapse" data-bs-target="#result7" aria-expanded="false" aria-controls="result7"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
355        </div>
356        <pre id="result7" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">[
357  {
358    &#34;message&#34;: &#34;docs: Document repeat(exp)&#34;,
359    &#34;name&#34;: &#34;Nico Williams&#34;,
360    &#34;parents&#34;: [
361      &#34;https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4&#34;
362    ]
363  },
364  {
365    &#34;message&#34;: &#34;Mention -n in IO-section and for input/inputs&#34;,
366    &#34;name&#34;: &#34;Nico Williams&#34;,
367    &#34;parents&#34;: [
368      &#34;https://github.com/jqlang/jq/commit/c4d39c4d22f2b12225ca1b311708f7e084ad9ff8&#34;
369    ]
370  },
371  {
372    &#34;message&#34;: &#34;Fix iteration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happened because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.&#34;,
373    &#34;name&#34;: &#34;Nico Williams&#34;,
374    &#34;parents&#34;: [
375      &#34;https://github.com/jqlang/jq/commit/174db0f93552bdb551ae1f3c5c64744df0ad8e2f&#34;
376    ]
377  },
378  {
379    &#34;message&#34;: &#34;docs: point to Libera.Chat instead of Freenode&#34;,
380    &#34;name&#34;: &#34;Nico Williams&#34;,
381    &#34;parents&#34;: [
382      &#34;https://github.com/jqlang/jq/commit/29cf77977ef52eec708982b19bf9d2ec17443337&#34;
383    ]
384  },
385  {
386    &#34;message&#34;: &#34;Missing \&#34;va_end\&#34; call. This was found by running the cppcheck static analysis where it shows as error.&#34;,
387    &#34;name&#34;: &#34;Nico Williams&#34;,
388    &#34;parents&#34;: [
389      &#34;https://github.com/jqlang/jq/commit/55e6e2c21829bd866bd4b18ee254b05c9020320a&#34;
390    ]
391  }
392]
393</pre>
394      </div>
395      <p>Here we're making an object as before, but this time the <code>parents</code>
396field is being set to <code>[.parents[].html_url]</code>, which collects
397all of the parent commit URLs defined in the parents object.</p>
398      <hr />
399<p>Here endeth the tutorial! There's lots more to play with. Go
400read <a href="../manual/">the manual</a> if you're interested, and <a href="../download/">download
401jq</a> if you haven't already.</p>
402    </main>
403
404    <footer class="bd-footer bg-body-tertiary">
405      <div class="py-3 text-center">
406        <p>
407          This website is made with <a href="https://getbootstrap.com" target="_blank" rel="noopener">Bootstrap</a>,
408          themed with <a href="https://bootswatch.com" target="_blank" rel="noopener">Bootswatch</a>.
409        </p>
410        <p>
411          jq is licensed under the MIT license (code) and the
412          <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC-BY-3.0</a> license (docs).
413        </p>
414      </div>
415    </footer>
416    
416<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
417      integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
417
418  </body>
419</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.