All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
2answers
30 views

Pass variable within json payload in shell script

In the following scenario, which is the way to pass ${MY_ENV_VAR} in the payload? I will have to escape: a) the single quotes of the payload b) the double quotes of the value of the text json ...
0
votes
2answers
66 views

How to write routine to escape double quotes in a JSON string [closed]

I have to be efficient so I can't use tools like jq which loads up a big binary executable. I just want to escape double quotes in a string so it's safe for JSON. This isn't good enough: echo ' bad \"...
1
vote
1answer
268 views

Passing variable to jq to edit a json file

I am trying to pass a variable into jq like this '.Linux.date.$var' so far I have tried quoting them by name which is working fine. But I want to use variable to call them. I have this, which is ...
9
votes
4answers
2k views

Wrap all numerics in JSON with quotes

There are JSON data which contains some numeric values. How to convert all numerics to strings? (wrap with quotes) Example: { "id":1, "customer":"user", "plate":"BMT-216-A", ...
1
vote
3answers
3k views

How to extract a value from json response using shell script

{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"15114","self":"https://brg-jira-tst.state.mi.us/rest/api/2/issue/15114","key":"BRGTEST-11","fields":...
0
votes
2answers
872 views

How to convert shell output to JSON?

I have this output in the following and I am trying to convert it to JSON api format. I want to know how can I do it. rock64@rockpro64:~$ sh MACscript.sh eth0 11:1d:11:11:11:1d lo 00:00:00:...
5
votes
5answers
6k views

looping through JSON array in shell script

Below is the curl command output (file information about branch), need script or command to print file name, filetype and size. I have tried with jq but was able fetch single value ( jq '.values[]....
3
votes
1answer
7k views

How to escape new line characters for json?

I have a file that contains new line characters. I am posting the file via curl to a server that would parse it as json. It rejects the request due to the new line characters. But when I do: $(echo ...
11
votes
4answers
3k views

Why is the JSON content from heredoc not parsable?

I have a JSON fragment. The following does not work: VALUE=<<PERSON { "type": "account", "customer_id": "1234", "customer_email": "jim@gmail.com" } PERSON echo -n "$VALUE" | python -m ...
0
votes
2answers
892 views

Adding array entries to existing JSON document from plain text input

I have a situation where i have output of one command, like this, 192.168.1.84 192.168.1.85 i want to use this, and make changes in another file, i.e add this ip addresses one after another like in ...
0
votes
1answer
463 views

sed Argument List Too Long While Updating JSON [duplicate]

I've a JSON property which needs to be updated with base64. The flow is: prop_val=`base64 --wrap=0 < $prop_txt` sed -i 's@"property_specific": ""@"property_specific": "'"${prop_val}"'"@g' $...
0
votes
2answers
1k views

Is it possible to not escape double quotes and get the right json format?

I want to submit json data using httpie. If I use double quotes and escape the double quotes surrounding the key, it works. json="[ \ { \ \"count\": 3 \ } \ ]" echo $json [ { "...
1
vote
2answers
1k views

Where can I find shell script for parse JSON on busybox?

I have an IP camera with armv5tejl architecture. There I have busybox. I have to be able to parse JSON responses from curl. The problem is that I don't have programs like: jq, jshon, jsawk... It is ...
-3
votes
1answer
981 views

How to parse json output through shell / Python [closed]

I am running a curl command which gives me json response. Now I want to parse the response output to get the keys and corresponding values from the output or getting value for a particular key. I ...
2
votes
1answer
3k views

How to sort files based on the json property value inside the file?

I've downloaded list of videos via youtube-dl and each file has corresponding .json file containing certain properties. So I would like to sort the files based on the selected json property which is ...