All Questions

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

Loop into JSON Array in Bash Script

I make a curl request to an API and get a json return with jq. The result { "errors": [], "metadata": { "clientTransactionId": "", "serverTransactionId": "20190318164551347" }, "...
0
votes
1answer
43 views

Need to associate one field with another in event, using bash script

I've gotten most of what I need done, but am stuck at the last part. I need to download the campaign from this month, but the url is associated w/ a campaign id and not the month (makes sense). I need ...
3
votes
2answers
751 views

parse JSON and malipulate its object values

I have a json file named xyz.json as follows [ { "annotations": [ "a" , "b" , "c" ], "class": "image", "filename": "vc00_02201.png" }, { "annotations": [], ...
1
vote
1answer
77 views

Data Cleaning Using Shellscript

I want a combined query suitable for selecting rows where lang = en i.e. language is equal to English and removing the other rows while I convert this file from JSON to CSV. json2csv -i Downloads/30....
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 ...
1
vote
1answer
299 views

Variable in curl adds backslashes to string

I am trying to use curl based on some variables to create customers in Stripe, but when I assign the token to a variable it is giving me an error on Stripe saying that it does not exist. However, if I ...
2
votes
0answers
231 views

process JSON format with JQ tools [closed]

I want check format keys in bash script. In my json if any keys match this format key[0-9][0-9]_$ my script exit 1 else exit 2. I want use JQ tools. Bash: #!/bin/bash json=$(cat <<EOF {"key11"...
0
votes
1answer
2k views

Check whether any value is zero using jq and return 0 to the calling shell script

I have this JSON file: { "key11":1010, "key12":12120, "key13":12103 } How can I use jq to check whether any of the values corresponding to a key[0-9][0-9] are zero, making jq exit ...
4
votes
1answer
3k views

Match keys with regex in jq [closed]

I'm writing a script that analyses JSON input (jsonfile): { "key11":1010,"key11_yes":13,"key11_no":14, "key12":12120,"key12_yes":9,"key12_no":25, "key13":12103,"key13_yes":13,"key13_no":20 ...
1
vote
2answers
2k views

Identify .json files with empty arrays?

I have a folder with multiple .json files. There are certain files with empty arrays, Sample file : { "WarehouseActivity": [] } The file has no other data apart from the one shown above. I need to ...
0
votes
2answers
893 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
0answers
931 views

Create JSON to be passed as an argument to a method that updates cloud foundry service

Trying to pass a JSON object from one shell script to another. If I send a JSON object with one value it works with the following: objectStorageCupsConfigData='{\"containerName\":""\"$...
1
vote
1answer
120 views

Getting URL address from file and check HTTP code

I'm creating bash script to check what HTTP code a given URL returning. I have file with about 50k of URLs in JSON format; it's the first one (head of file): "responseHeader":{ "status":0, "...
1
vote
1answer
2k views

Parsing JSON with JQ

I'm using Bash to run the following script snippet on a Linux box. JSON file contents: [ { "id": 123456, "firstName": "John", "lastName": "Smith", "email": "user@domain.com" } ] The JSON file is ...
1
vote
4answers
8k views

How to grep/print value of a key in json that is stored in a variable?

I have a variable with nested json, a={"content":[{"JOB_STATUS_ID":283739,"PROGRAM_ID":57,"STATUS":"Completed","**DATA_DATE**":"2017-03-09 00:00:00","**START_TIME**":"2017-03-10 00:46:13","END_TIME":"...
0
votes
2answers
87 views

JSON correct construction

I'm generating a JSON file with a shell script but I can't find a solution to automatically get rid of the last comma just before the ending "}". Here is my code: echo "{" >> out_file for i ...
0
votes
2answers
3k views

Bash - loop through files and pull JSON value from corresponding keys in a master key file

I'm trying to make a bash script that loops through a file that contains a list of files (so it goes through each one of these files). While the files are open, I want to use another program (jq) to ...
-1
votes
1answer
133 views

Append value as parameter to shell script

I found the value of a response (curl) with sed and now i need some help to take the value that i printed in a file and to use it in another substring in the same .sh script This is the response of ...
1
vote
2answers
5k views

Extract UUID value from JSON returned from HTTP reply

I am trying to make a little script in shellscript that takes one serviceUuid from a response and use it. I just print the server response on a file called final.txt Now i need to extract the value ...
1
vote
2answers
314 views

Overcoming newlines with grep -o

I have a file similar to such. SampleOutput { "1": { "state": "RUNNING", "stats": { "name": "some-file", "uris": [ "some-example.com" ], ...
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 ...
2
votes
3answers
121 views

Delete Entries in File if the Same Entry Exists in a Master File

I have a JSON master config file whose value may be overwritten by a specific account's config file (also in JSON). The Master file has this structure: { "section1Configs": { "setting01": ...
-3
votes
1answer
982 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 ...
1
vote
3answers
5k views

single jq command write to different files

I have a JSON log file test.log: {"type":"1","fname":"AAA","lname":"bbb" } {"type":"2","state":"gujarat" } {"type":"3","city":"ahmedabad" } {"type":"3","city":"rajkot" } {"type":"1","...
11
votes
4answers
29k views

parse one field from an JSON array into bash array

I have a JSON output that contains a list of objects stored in a variable. (I may not be phrasing that right) [ { "item1": "value1", "item2": "value2", "sub items": [ { "...
3
votes
1answer
941 views

Convert json numbers to strings in the shell

When parsing json, the command-line tool jshon converts numbers to scientific notation, and sometimes tries to round them. To avoid these problems, I want jshon to consider these numbers as strings. ...
0
votes
2answers
5k views

Convert json mapping object to managed csv row using bash script

I have json mapping under properties key as below in a file Customer.json, { "customer": { "properties": { "customerId": { "type": "string", "...