Questions tagged [jq]
Questions about the command line JSON processing tool jq.
401 questions
5
votes
1
answer
219
views
Merging multiple JSON data blocks into a single entity
I'm using an API (from SyncroMSP) that returns paginated JSON data. I can obtain the number of pages, and I can obtain the data with a tool such as curl. Each chunk is valid JSON but it only contains ...
5
votes
2
answers
187
views
Update object inside array inside another JSON object
I have a huge JSON object with an array of objects inside it. I have to add key:value pair to a specific object in the array. For example, let the input object is:
{
"a": {
"b&...
3
votes
1
answer
137
views
use jq to pick a key out of a list of a list of objects and raw output with newline separation for outer array items
I want to output a specific key of list of a list of hashes as lines where each outer array item is seperated by an empty line. To illustrate:
Input is:
[
[
{
"visible": true,
...
1
vote
1
answer
49
views
jq select multiple elements from an array
I have a JSON which looks like:
{
"type": "server-firmwareinventory-list-1",
"members": [
{
"type": "sever-hardware-firmware-1",
&...
1
vote
1
answer
46
views
json formating with jq for json nested objects
how do I get jq to take json like this:
{
"responseHeader":{
"status":0,
"QTime":1
},
"cluster":{
"collections":{
"...
3
votes
2
answers
325
views
jq create object with property name from variable
$ n="foo"; echo "{}" | jq --arg n "$n" '. += { "$n": $n }'
{
"$n": "foo"
}
My reading of https://jqlang.github.io/jq/manual/#types-and-...
3
votes
2
answers
564
views
Emulate gron using jq
I recently discovered jq and gron.
For my use case, gron is sufficient, but I am a little worried by lack of development. There are some bugs that have not been addressed in an year, while I see that ...
11
votes
3
answers
704
views
jq - ip addr show in tabular format
I'd like to pretty print the ip addresses and show the output in in tabular format, including all the meta data such as valid_lft, temporary, etc.
I figured out that ip -j addr show eth0 is giving me ...
-1
votes
1
answer
154
views
bash loop with jq [closed]
How can I update a json file using jq in a loop as below ? json file need to have the .queryToken updated and .result array appended using json in curl response body
while true
do
curl -k --location ...
3
votes
2
answers
212
views
Pairing and structuring elements from a JSON array, with jq
[
{
"key": "@timestamp",
"value": "2024-08-21 03:02:57.871"
},
{
"key": "@message",
"value": "Aug 21, ...
4
votes
1
answer
2k
views
What does it mean to echo multiple strings into a UNIX pipe?
I just saw an example of using echo to put multiple things into the pipeline (for jq).
echo '{"A": {"a": 1}}' '{"A": {"b": 2}}' '{"B": 3}' |\
jq --...
0
votes
1
answer
310
views
How to use jq to create a JSON object with path-value pairs (instead of key-value pairs)?
In jq scripts, I needed to create json objects using pairs of path-values (which are more general than the old key-value pairs). That is, instead of a key, I need to use a path, so that the value is ...
0
votes
1
answer
492
views
How to escape symbols in jq query?
I try to get area of JSON created by kubectl as another user.
runuser -l username -c "kubectl get ing -A -o json | jq --arg namespace "default" -r '.items | map(select(.metadata....
-2
votes
2
answers
103
views
bash script replace credentials in json file
I have json file like this:
{
"sdpSemantics": "unified-plan",
"iceServers": [
{
"urls": "stun:1.1.1.1:3478"
},
{
"...
5
votes
2
answers
434
views
Using jq to copy field from one object to a later object in a JSON array
I have a series of events represented in a JSON array. I want to move data in the fields of earlier events to a later event. Is there a way to do this with jq?
Here is an example of what I'm looking ...