Skip to main content

Questions tagged [json]

JSON (JavaScript Object Notation) is a lightweight data representation format that resembles JavaScript source and that is can be easily red by machines and edited by humans with some effort.

1 vote
2 answers
78 views

How to pretty print one column of piped input?

bash 4.4.20 and jq-1.6 on RHEL8 I get this nice output from jq and column. Hard to read, though. pgbackrest info --output=json \ | jq -r '.[] | .backup[] | "\(.type) \(.label) \(.info.delta)...
RonJohn's user avatar
  • 1,473
0 votes
0 answers
51 views

libvirt: "Error starting domain: internal error: failed to parse JSON: nesting too deep"

I'm on Fedora Linux 42.20250824.0 (Sway Atomic), running libvirt version 11.0.0, qemu-img version 9.2.4 (qemu-9.2.4-1.fc42) and virt-manager version 5.0.0, all installed as layered packages. Using ...
magnusTre's user avatar
1 vote
2 answers
187 views

Extracting two (or more) related values from an array of JSON objects

Consider a contrived example using a JSON object such as this, where I want to extract the related id, firstname, and lastname fields for each of many array objects into shell variables for further (...
Chris Davies's user avatar
2 votes
1 answer
88 views

Append to matching children of an arbitrarily deep array

I am attempting to edit an OpenAPI specification by changing all parameters to be nullable. A parameter definition looks like this: { "name": "foo", "required": ...
miken32's user avatar
  • 608
8 votes
3 answers
981 views

How can I make jq assign values to environment variables in one command?

Say, I provide jq with the following JSON body as input: {"person1": {"name": "foo"}, "person2": {"name": "bar"}} Is it possible to have jq ...
Shuzheng's user avatar
  • 4,941
5 votes
2 answers
389 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 ...
Chris Davies's user avatar
6 votes
2 answers
382 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&...
Vlado B.'s user avatar
3 votes
1 answer
300 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 separated by an empty line. To illustrate: Input is: [ [ { "visible": true, ...
Orangenhain's user avatar
0 votes
1 answer
115 views

removing first and last character and empty spaces from a json file [closed]

I have given sets of different input files as shown sample below cat out.txt [ { "regional_unit": "node", "source_name": "1753250187_SPS", "...
Vikrant Singh Rana's user avatar
0 votes
3 answers
386 views

Convert json data to comma separated string

I have a json object that has an unknown number of variables, like this: { "var1": 123, "var2": 456, "var3": 789 } How can I automatically convert it to form ...
teeeeee's user avatar
  • 305
1 vote
1 answer
74 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":{ "...
Claudio Favaro's user avatar
3 votes
2 answers
2k views

How to generate double quoted JSON string with escaped double quotes?

I sometimes need to write JSON strings containing a string value that is itself a JSON string. e.g. In the following JSON object: echo '{"rec" : " {\"id\": 1, \"name\&...
tinlyx's user avatar
  • 1,086
3 votes
2 answers
2k 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-...
Richard Barraclough's user avatar
-2 votes
3 answers
150 views

Awk to pick up json values

I am trying to get the job status from the below json file.. but while using awk it is returning { "id": 10870, "type": "job", "url": "/api/v2/...
user984993's user avatar
3 votes
2 answers
706 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 ...
Francesco Potortì's user avatar

15 30 50 per page
1
2 3 4 5
38