Quantcast
Channel: Active questions tagged jq - Stack Overflow
Browsing all 657 articles
Browse latest View live
↧

Transposing jq array elements (building x*y key/value pairs from x arrays of...

I have the following AWS CLI JSON output that contains Instance ID, IP address and some other values from my AWS tags (a list of desired FQDNs and if a proxy should be used or not):[ [ {"InstanceId":...

View Article


Using jq or alternative command line tools to compare JSON files [closed]

Are there any command line utilities that can be used to find if two JSON files are identical with invariance to within-dictionary-key and within-list-element ordering?Could this be done with jq or...

View Article


Using jq how can I replace the name of a key with something else

This should be easy enough... I want to rename a few keys (ideally with jq), whatever I do seems to error though. Here is a JSON example below:$ cat fruitfile.json[ {"fruit": "strawberry","veg":...

View Article

Json Object Parsing using shell script

I am trying to parse below json object using shell script:country.json {"countries": [ {"country":"India","city":["India1","India2","India3"]}, {"country":"USA","city":["USA1","USA2","USA3"]} ] }and my...

View Article

Command line getting occurrences of text within brackets following a...

I am trying to get some specific text from logcat. It could be repeating multiple times. Example content would be:..., stateEventTime=2025-01-09T17:22:05.635Z)],...

View Article


Using jq with the value of a variable as field value

I have a JSON file which I got via curl with hourly energy prices.I can output the price for 6 o'clock withjq '.energy | .todayHours | .[6] | .priceIncludingVat'< "$JSON"I get the actual hour via...

View Article

Filtering key and specific value

Using the following json document :{"connections": {"7MXYADN-WDXFLSC-3JBG57R-JHZXXYP-ZROJDED-YFQYNCL-WTHPSOQ-KHOLXAP": {"address": "","at": "0001-01-01T00:00:00Z","clientVersion": "","connected":...

View Article

How do I turn tagged recursive object into pairs of tag and absolute path?

How do I turn a recursive object { id, name: { data }, children: self[] } into array of something like { id: id, name: name.data | join('/') } ?For example, I'd like to convert given following data[...

View Article


Round numbers anywhere in a JSON document

I want to compare lots of JSON-Documents without caring about a precision more then 2 digits. I want to round any number in a JSON-Document, but I do not know where in the documents numbers are (but...

View Article


GitLab CI syntax to write FOR loop statement?

Below is the script mentioned in the gitlab-ci.yml file. This GitLab CI configuration is valid. But, when the CI/CD build is run, the job fails. Is it something to do with the FOR loop syntax?...

View Article

How to JQ select a record where a sub-node matches both values

I have a JSON similar to the following. I have multiple records, and I'm trying to extract the field value for "RecType" from the record which has the tag where Key==name and Value==qwerty.{"Records":...

View Article

yq to get values from key value pair

I have a simple values.yaml file which has below data:images: tags: one: abc:v0.3-16-07 two: xyz:ng-0.23.0 pq: qaa:0df1e21e752b3d3.2020-04-27_1Using yq -r --yaml-output ".images.tags" values.yamlI can...

View Article

Powershell not handling whitespaces in jq string interpolation command

I'm trying to follow this: https://jqlang.org/manual/#string-interpolationIn powershell I try this:echo '{"key": "value"}' | jq '\"Theinputwas:\(.key)\"'And get this: "Theinputwas:value"But, if I try...

View Article


How to extract Kubernestes PODS mac addresses from annotations object

I am trying to extract the mac or ips addresses under metadata.annotations using either kubectl get po in json filter or using jq. other objects are easy to manipulate to get those values.kubectl get...

View Article

jq: How to slurp mid-filter (convert separate json objects to an array)

I am parsing Elastic logs that look like$ cat my_log_file.txt:{"level": "INFO", "message": "foo"}{"level": "WARN", "message": "bar"}{"level": "WARN", "message": "baz"}Because they're one per line,...

View Article


jq to replace text directly on file (like sed -i)

I have a json file that needs to be updated on a certain condition. Sample json{"Actions" : [ {"value" : "1","properties" : {"name" : "abc","age" : "2","other ": "test1" } }, {"value" :...

View Article

Create JSON file using jq

I'm trying to create a JSON file by executing the following command:jq --arg greeting world '{"hello":"$greeting"}'> file.jsonThis command stuck without any input. Whilejq -n --arg greeting world...

View Article


how to "unpack" nested json data into csv-like with jq

having a data eg like:[ {"user": {"foo": "a1","bar": "b1" },"data": [ {"baz": "c1.1","beq": "d1.1" }, {"baz": "c1.2","beq": "d1.2" } ] }, {"user": {"foo": "a2","bar": "b2" },"data": [ {"baz":...

View Article

How to extract specific fields of JSON with jq based on partially match of...

Grafana log have this format.{"log": "message","stream": "stdout","time": "2025-02-27T14:52:50.01405178Z"}I need to extract all fields with the time equals to the current minute I can define with--arg...

View Article

Cannot index string with string "name" - CSV output from JSON

I'm trying to output data in a JSON file I have with a few thousand rows to CSV. The JSON components follow this general pattern:{"name": "pickles","aliases": ["birds" ]}{"name": "cheese","aliases":...

View Article
Browsing all 657 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>