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

jq command to iterate on JSON array with values having space

Input filename is project.json, and its content is:{"package": [ {"path": "src","default": true } ],"name": "Sample","replacements": [ {"filename": "/src/main/CO_Config.xml","stringToReplace":...

View Article


jq: easiest way to recursively remove objects based on object value condition

I would like to use jq to remove all dictionaries within a JSON "object" (I used that term generally to refer to either an Array or a Dictionary) thata) contain a key named "delete_me", ANDb) where the...

View Article


jq erroring when using square brackets [closed]

I am trying to use jq to get a string from a json around compute instance information, however jq is erroring whenever I use a square brackets. The code works on only tools like jqplay but as soon as I...

View Article

jq gets objects that contain certain key

I'm strugling to find a solution to this, every other question I've found its quite close but still not the answer.I've got a huge json, and it has many objects and arrays inside.What I'd like do to is...

View Article

Deleting multiple keys at once with jq

I need to delete multiple keys at once from some JSON (using jq), and I'm trying to learn if there is a better way of doing this, than calling map and del every time. Here's my input data:test.json[...

View Article


How parse json value into array with jq

I have this{ "1": { "Split": { "result": "first_image" } }, "2": { "Split": { "result": "second_image" } } }I tried .[].Split.result but it gives be below result;"first_image""second_image"but I want...

View Article

How to remove double-quotes and \ in jq output without making it single line...

I have the following json output{"secrets": [ ["{"," \"name\": \"testSecret\","," \"vault-apikey\": \"kv\","," \"vault-value\": \"sabrinaTest\"","}" ] ]}But I need the output to be a little cleaner and...

View Article

How check if there is an array or an object in jq?

For example, I want to extract the values from a key, but that key sometimes contains an object (I mean just one value) or sometimes contains an array (i mean multiples values). HOw check if there is...

View Article


How to create github actions matrix using boolean input

I am trying to construct a strategy matrix for environments based on boolean selection for the environment but I am unable to construct it. How can I construct based on if Dev is selected or QA is...

View Article


How to use JQ command to generate random string of length 5, consisting of...

I am not getting any function to generate random string using JQ filterI tried to use random and rand function to generate random strings, but JQ is giving error saying random or rand is not defined. I...

View Article

Proper use of select in select in jq

I have a file[{key: 'value',key1:{key:'value'},fields:[{to:{id:'value'},field:{id:'value',name:'value'}},{key:'value'}]}]I need to find elements of initial array which have and array .fields[] which...

View Article

How to install JQ on Mac on the command line?

I need to know the most efficient way of installing JQ on Mac (El Capitan). The code is downloaded to my Mac but I would like to know how I can install and operate it via the command line.

View Article

jq sort by version as string

I'm trying to sort the following json reponse to pick the latest version:[ {"TagVersion": "1.0.11" }, {"TagVersion": "1.1.8" }, {"TagVersion": "1.0.10", }, {"TagVersion": "1.0.9", }, {"TagVersion":...

View Article


Map Keys with value of Subkeys in jq

I try to reformat the output of the sensors command:sensors -j ftsteutates-i2c-0-73{"ftsteutates-i2c-0-73":{"Adapter": "SMBus I801 adapter at efa0","VCC 3.3V":{"in0_input": 3.331 },"3.3V...

View Article

How to filter JSON containing any of possible values, using jq

I have the following json fragment:["FOO": {"name": "Donald","locations": ["Stockholm","London"] },"BAR": {"name": "Walt","location": ["Stockholm","Munich"] },"BAZ": {"name": "Jack","location":...

View Article


With jq Intersection of 2 json objects

I have a first json structure.All the values are always null.{"A": {"A1": {"A11": null,"A12": null } },"B": {"B1": {"B12": null },"B2": null },"C": {"C1": {"C11": null,"C12": null },"C2" : {"C21":...

View Article

Not getting expected result from Bash script to remove IPs from JSON [closed]

I have a couple of bash scripts that I'm trying to put together:Appends an IP to a JSON file, and adds the IP and Epoch Time added to a CSV (ip_addresses.csv) with the headers "IP_Address" and...

View Article


Print data for an object based on value(variable) for a key in jq output...

I have this JSON :[ {"id": "1","agent": "23ef","displayName": "foo.com" }, {"id": "2","agent": "23gh","displayName": "foo2.com" }, {"id": "3","agent": "23gf","displayName": "boo.com" }]Wanted to get...

View Article

Trying to get the last object from a JSON list

I have the following JSON data :$ cat toto.json{"method": "GET","path": "/users/sign_in","status": 500,"exception.class": "NoMethodError","exception.message": "undefined method...

View Article

Jq fails and shows no output on SSE endpoint through curl

Working example with Jqecho 'data:{"id":"66fc29f995e5b148fe5c7f7d","summary":"Balans: 305.37","level":"info","date":"2024-10-01T16:57:29.873+00:00"}' | sed 's/data://g' | jq '.summary'Even with new...

View Article
Browsing all 543 articles
Browse latest View live