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.

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 ...
Chris Davies's user avatar
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&...
Vlado B.'s user avatar
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, ...
Orangenhain's user avatar
0 votes
1 answer
54 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 rana's user avatar
0 votes
3 answers
128 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
  • 229
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":{ "...
Claudio Favaro's user avatar
3 votes
2 answers
692 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,002
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-...
Richard Barraclough's user avatar
-2 votes
3 answers
103 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
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 ...
Francesco Potortì's user avatar
0 votes
4 answers
103 views

How to replace pattern in last line

I'm trying to replace "}," by "}" from the last line of a file : My /etc/firefox/policies/policies.json file like this because I added the certificate lines using a for loop : $ ...
SebMa's user avatar
  • 2,341
-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 ...
Anil Samuel's user avatar
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, ...
Anil Samuel's user avatar
1 vote
1 answer
221 views

Modify a key value with another one containing a path using slashes

I have a couple of hours (I started today) experience in Bash. I have been trying multiple times to modify the value from a key in a json file using it. I know that it's much easier in python but I ...
Diego Alejandro Gómez Pardo's user avatar
-2 votes
1 answer
230 views

How to replace a parameter's value in json file with a value taken from a different text file

I have a a large number of JSON files on a Linux machine, where I need to change the value of a parameter with value taken from a different text file. E.g.: If the JSON file has values like: { "...
vishal's user avatar
  • 97

15 30 50 per page
1
2 3 4 5
38