
Sign up to save your podcasts
Or
In this episode we will continue looking at basic filters. Then we
This filter allows parts of JSON arrays or strings to be
The first number is the index of the elements of the array or string,
This example shows using an array and extracting part of it:
Here we use the seq command to generate the numbers 1-10
For a string, the idea is similar, as in:
Notice that we provide the JSON string quotes inside single quotes
Both of the numbers may be negative, meaning that they are offsets
So, using '.[-7:-4]' in the array example gives the same
Similarly, using '.[-12:-9]' gives the same result as
As a point of interest, I wrote a little Bash loop to show the
Finally, here is how to get the last character of the example string
This filter generates values from iterating through an array or an
The strings in the array are returned separately, not as an array.
It can also be used to iterate over values in an object:
This iterator does not work on other data types, just arrays and
An alternative iterator .[]? exists which ignores
Ignoring errors:
There are two operators that can be placed between filters to combine
The comma (',') operator allows you to chain together
With the comma operator the input to jq is fed to all of
For example, if we take the output from the HPR stats page which was
This applies the filter .shows (an object
The pipe ('|') operator combines filters by feeding the
For example, if we extract the 'shows' object from
Interestingly, chaining two object identifier-index filters
(Note: to answer the question in the audio, the two filters shown can
We will see the pipe operator being used in many instances in
It is possible to use parentheses in filter expressions in a similar
Here we are using a file called countries.json obtained
I will show ways in which the structure can be examined and reported
Another search of the countries.json file, this time
In the next episode we will look at construction - how new
Footnote: A Bash loop to show positive
Note that variable y doesn't contain a valid JSON
4.2
3434 ratings
In this episode we will continue looking at basic filters. Then we
This filter allows parts of JSON arrays or strings to be
The first number is the index of the elements of the array or string,
This example shows using an array and extracting part of it:
Here we use the seq command to generate the numbers 1-10
For a string, the idea is similar, as in:
Notice that we provide the JSON string quotes inside single quotes
Both of the numbers may be negative, meaning that they are offsets
So, using '.[-7:-4]' in the array example gives the same
Similarly, using '.[-12:-9]' gives the same result as
As a point of interest, I wrote a little Bash loop to show the
Finally, here is how to get the last character of the example string
This filter generates values from iterating through an array or an
The strings in the array are returned separately, not as an array.
It can also be used to iterate over values in an object:
This iterator does not work on other data types, just arrays and
An alternative iterator .[]? exists which ignores
Ignoring errors:
There are two operators that can be placed between filters to combine
The comma (',') operator allows you to chain together
With the comma operator the input to jq is fed to all of
For example, if we take the output from the HPR stats page which was
This applies the filter .shows (an object
The pipe ('|') operator combines filters by feeding the
For example, if we extract the 'shows' object from
Interestingly, chaining two object identifier-index filters
(Note: to answer the question in the audio, the two filters shown can
We will see the pipe operator being used in many instances in
It is possible to use parentheses in filter expressions in a similar
Here we are using a file called countries.json obtained
I will show ways in which the structure can be examined and reported
Another search of the countries.json file, this time
In the next episode we will look at construction - how new
Footnote: A Bash loop to show positive
Note that variable y doesn't contain a valid JSON
1,973 Listeners
117 Listeners
5,938 Listeners
283 Listeners
265 Listeners
89 Listeners
43 Listeners
154 Listeners
35 Listeners
7,874 Listeners
36 Listeners
21 Listeners
314 Listeners
92 Listeners
20 Listeners