Category "jq"

Read a value out of a "complicated" JSON file [closed]

I'm using jq, but I didn't manage to get a value extracted from a .json-file (I got generated by mediainfo) in my batch-script. How can I get

jq - return array value if its length is not null

I have a report.json generated by a gitlab pipeline. It looks like: {"version":"14.0.4","vulnerabilities":[{"id":"64e69d1185ecc48a1943141dcb6dbd628548e725f7cef7

jq: Select using 2x seperate-level keys

Using jq on JSON data ... I'm trying to select records where FromPort is 80 and CidrIp is 0.0.0.0/0 within the same element of the record. Here is the query: ca

JQ- print specific key value pair

I have this JSON: { "time": "2022-02-28T22:00:55.196Z", "severity": "INFO", "params": [ {"key": "state", "value": "pending"}, {"key"

Data extraction from array using jq

Please help me to figure that one out... I want to get the ID where the name is - terraform-02 jq '.[] | map(select(.name == "terraform-02"))' - didn't work, to

jq wildcard as object in getpath split

Given a basic json { "notKnown": { "alpha" : { "hello":"world" } } } and then using getpath with a wildcard as an object

Removing and adding key-value from JSON file using jq

I have an json file as follows below- { "key1": [ "value1" ], "key2": [ "value2" ], "key3": [ "value3" ], "key4": { "name": "value

jq error (at <stdin>:25): Cannot index string with string "data1"

I have a json file with data as below : { "0cef7017-e6af-4c92-9e7c-4db1d7afc733": { "Show": [ "TEST1", "TEST2" ], "data1": 12345,

JQ map objects to array

I have this input data: [ { "attributes": { "created": "2021-10-18T12:02:39+00:00", "enabled": true, "expires": null, "notBefore":

parse error: Invalid numeric literal at line 1, column 6

The 1 liner to grab the ticker works fine from commandline, but i get this error running in a script. I run the 1 liner that grabs TICKERD from commandline, th

Use jq to parse key path for each each leaf

(I’m not sure the technical terms to use but can update the question if someone can clarify the terminology I’m lacking for what I'm trying to do. I

How to read each cell of a column in csv and take each as input for jq in bash

I am trying to read each cell of CSV and treat it as an input for the JQ command. Below is my code: line.csv | Line | |:---- | | 11 | | 22 | | 33 | Cod

jq replace part of value in json

I need to replace part of a value from a json output. I could easily do this using sed -i however it would also replace other parts of the file I don't want it

Can I pass a string variable to jq not the file?

I want to convert JSON string into an array in bash. The JSON string is passed to the bash script as an argument (it doesn't exist in a file). Is there a way o

Can I pass a string variable to jq not the file?

I want to convert JSON string into an array in bash. The JSON string is passed to the bash script as an argument (it doesn't exist in a file). Is there a way o

How to limit properties of a JSON object given array of property names using JQ?

Assuming I have the following JSON object (which is just an example): { "foo": 1, "bar": 2, "baz": 3 } And the following JSON array (another example)

jq: find and replace within filter

I return a few json values from an API feed using this command: curl -s -u user:pass -H 'my header' https://example.com/data.json | jq -cr '.[] | {id: .id, con

How do I group values to an array for the same field value in jq?

I have json data that looks like [ { "session": "ffe887f3f150", "src_ip": "81.71.87.156" }, { "session": "fff42102e329", "src_ip": "143.19

How to append json array using jq+shell in a loop?

I can create a json object with an array using jq like this echo '{"input":{"names":[]}}' | jq --arg val "alice" '.input.names[0] += $val'| jq --arg val "bob"

jq how to pass json keys from a shell variable

I have a json file I am parsing with jq. This is a sample of the file [{ "key1":{...}, "key2":{...} }] [{ "key1":{...}, "key2":{...} }] ... each line is a list