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

calculate consecutive numeric values, but it fails because of floating point...

With a Json field like the one below, if eventId is a continuous value,I would like to add the value of the message field.However, even if eventId is continuous, if the message field starts with #...

View Article


JQ does not process part of the data

I can simplify the question by providing a link to the source data:curl -sX GET...

View Article


How to transform JSON array elements recursively into objects using JQ filter

I want to transform this JSON{"property": "value","array1": [ {"name": "A","propertyA1": "1","propertyA2": "2" }, {"name": "B","propertyB1": "1","array2": [ {"name": "C","propertyC1": "1","propertyC2":...

View Article

jq manipulate object where field matches regex

I need to delete a field .xxx from an object at any depth of the tree where another field .myfield matches a regex.I know how to match a precise content:walk(if type == "object" and .myfield == "my...

View Article

How to get this output in TABLE format

I want to get the below command output in table format using Linux commands:aws --region us-east-1 cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ConsoleLogin...

View Article


Use jq to parse local time into Golang RFC 3339

I have "2024-12-01 00:00:00" in local TZ (Europe/Berlin) and want to parse/convert this into RFC3339 for Go time.Parse which would be "2024-12-01T00:00:00+01:00".I've tried various variants...

View Article

How to find and merge two json objects in a bash script using jq

I need to merge two json objects by key value in a bash script:It is necessary to find by key (MAC address) the corresponding object (value) and add to its pairs the key: value pair of another...

View Article

Terminating jq processing when condition is met

I am using jq to search for specific results in a large file. I do not care for duplicate entries matching this specific condition, and it takes a while to process the whole file. What I would like to...

View Article


Parsing json output with JQ - Searching for patterns

I have the following json (based on ndpi output){"src_ip":"x.x.x.x","dest_ip":"x1.x1.x1.x1","src_port":48318,"dst_port":443,"ip":4,"proto":"TCP","ndpi": {"flow_risk": {"35": {"risk":"Susp...

View Article


Ansible compare two JSON responses

I'm using Ansible to call the same administration API on two different servers and then selecting the core details of the applications from the responses using jq.According to Ansible type_debug the...

View Article

jq query with multiple conditions not working

I'm trying to run a jq query with multiple conditions, where the fields in the condition are in different parts of the JSON. The second condition isn't narrowing things down, and I need help figuring...

View Article

How to update JSON file in shell script without using jq?

I am using shell script to update JSON. Previously I used jq command to read/write an JSON object. However it seems not every bash environment support jq command. I tried to resolve this issue by...

View Article

Subscribing to a Window event with Sway

I'm using sway and would like to perform some action in bash, when a certain window is created. Right now this is what I have:swaymsg -mt subscribe '["window"]' | jq 'select(.change == "new") |...

View Article


Replacing select condition with jq's `IN`

Given the simplified input:[ [ "gpu" ], [ "disk" ]]I would like to select the arrays for which the first element is "gpu".I can do it with a simple condition:map(select(.[0] == "gpu"))[ [ "gpu" ]]But I...

View Article

How to iterate over JSON array with jq?

I'm building a script to download all CodeCommit repositories at once.REPOS=$(aws codecommit list-repositories)echo $REPOS | jq -r '.[]' | while read name ; do git clone XXXdoneIn first line I get all...

View Article


How to get key names from JSON using jq

curl http://testhost.test.com:8080/application/app/version | jq '.version' | jq '.[]'The above command outputs only the values as...

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


Why can't $module be used as a variable name in jq?

Is this behaviour of jq, w.r.t the non-allowed use of $module as a variable name, specified anywhere?$ jq -n --arg 'module''X''$module'jq: error: syntax error, unexpected module, expecting IDENT or...

View Article

Converting part of a multiqc_data JSON to TSV with jq

I'm trying to convert a multiqc_data.json file to a tsv file. Specifically, I only need part of data from "report_general_stats_data" section. The structure is:{"report_general_stats_data": [...

View Article

How to use .fieldname to jq's startswith

In the jq script below I want to print either the concatenation of the first_name and the last_name or just the last_name.$ echo '{"first_name": "John", "last_name": "Johnson"}' | jq -c '{"name": (if...

View Article
Browsing all 538 articles
Browse latest View live