I’m trying to create a script to read the return code from a json from a curl command. my curl command is: The json output is: How can read the value “http_httpCode#HTTP Code” if 1650468248 is a dynamic value? Answer You could use to_entries so you can use .value to target the ‘unknown’ key: Online demo Another approach by just
Tag: json
JQ – Deep child replace through wildcard search, but check parent presence with merge to the original JSON
This is a kind of extension to my previous question JQ – Deep child value replace through wildcard search and merge to the original JSON I want to check the presence of a particular key in some parents before replacing the child. Loosely, translated to CSS selector, I want something like * > fixedKeyCheckPresence > * > fixedKeyCheckValue Input: Expected
Split/Slice large JSON using jq
Would like to SLICE a huge json file ~20GB into smaller chunk of data based on array size (10000/50000 etc).. Input: Currently running in a loop to get the desire output by incrementing x/y value, but performance is very slow and takes very 8-20 seconds for a iteration depends on size of the file to complete the split process. Currently
Json response data extraction using linux command
Below is the json response of an api endpoint, I wanted to get the id value of specific name in the below array of json response. eg: I wanted to get id value(10002) of name test3, with the help of name key. Using jq I’m able to select the name key, but I’m not to find a way to get
Non variable recognition on Syspass API Bash Script
When i input a variable on the curl with the json indexed, it takes the string value of the variable, if i scaped the double-quotes, it returns me a sintax error because of in a json request u have to input the data with double-quotes. Example: The curl json request works if i input the data manually, but with the
jq script file not getting the key/value pair
I would like to put all jq filters inside a text file and use the jq -L option to execute the filters. However, I can’t get this simple thing working. Inside my sample2.json file, I have: Inside my json2csv file, I have: When I do: The output is the whole sample.json file, like this: but I would expect the output
how to for loop a jq array result in shell script
I have a json data as below now I can use below command line to get a list containing two dict, each dict have a key “data”, value is a list, I want to print each dict with a loop in shell script My except in each loop have printed a dict, total have 2 dict But it seems like
remove comma in jsonpath template using bash
I have a JSON path template query. i’m redirecting it to csv. getting comma in a message from above output , i want to replace the comma with space for the second column(message) in the bash script. Anyone has any thoughts on how can achieve this. Expected result Answer Assuming you can change the field delimiter to a character known
Use Route53 template in cloudformation with Cloudfront
Hi Team, I am going to create a route53 record with cloudfront please find the cloud-formation code and in which I am getting an error while create a stack. Basically I want to create a CNAME record by using cloudfront domain name. Please help me out in this. Answer You can use the below template I should raise as you’re
Retrieve secrets from AWS Secrets Manager
I have a bunch of secrets (key/value) pairs stored in AWS Secrets Manager. I tried to parse the secrets using jq as: It retrieves the value stored in .PASSWORD, but the problem is I not only want to retrieve the value stored in key but also want to retrieve the key/value in the following manner: By running the above command