Quantcast
Browsing all 524 articles
Browse latest View live

jq: error (at :0):Cannot iterate over null (null) [closed]

Trying to run a program, an error message like this appeared in TermuxI need some help to run this program well.I have little knowledge about Termux so i don’t have any solutions to solve this problem....

View Article


Looping over arrays from jq in shell scripts [closed]

I am struggling to loop over an array from jq in a shell script. Every stackoverflow article that I have found does not work.Given the...

View Article


Strange behaviour of the alternative operator //

Using JQ 1.5 I've problems understanding the output of the alternative operator // in a specific situation.Given this input:{"a": 42,"b": false,"c": null}I expected the expression (.a, .b, .c, .d) //...

View Article

Dump all key pair of a json with JQ

Today I have big troubles in parsing huge json files (bigger than a megabyte) with only pure bash functions (performance issues), so I would like to use JQ parser https://jqlang.github.io/jq/ to speed...

View Article

How to merge json object with same keys?

Here are the 2 items in one array:{"SysID": "12345","Name": "abc"}{"SysID": "12345","Name": "def"}{"SysID": "23456","Name": "hij"}{"SysID": "23456","Name": "klm"}{"SysID": "23456","Name": "nop"}I would...

View Article


jq how to merge multiple arrays?

I have the following data, the output of multiple jq pipes: [ {"Russia": 1073849 } ] [ {"Spain": 593730 } ] [ {"France": 387252 } ] [ {"UK": 371125 } ]My desired output is: [ {"Russia": 1073849 },...

View Article

Parse multilevel json into a csv using jq tool in unix

I have a multilevel json like so:{"id": "id123","details": {"prod": "prod123","etype": "type1" },"accounts": [ {"bankName": "bank123","accountType": "account123","openingBalance": "bal123","fromDate":...

View Article

Can not extract more than one key when looping over an array with jq in bash...

This works:#!/bin/sh -ecat << EOF > error.json[ {"path": "path1","path_with_namespace": "path_with_namespace1" }, {"path": "path2","path_with_namespace": "path_with_namespace2" }]EOFjq -c...

View Article


jq referencing an index/key with its inner values

I have a JSON similar to the following:File: my_data.json{"hosts": {"1.2.3.4": { "name": "name4", "env": "test", "options": "" },"1.2.3.5": { "name": "name5", "env": "prod", "options": "opt1,opt2"...

View Article


JQ print two arrays values using the same index

in the following example I have two arrays (timestamp and values) that are related by the same index, so timestamps[0] is related to values[0], timestamps[1] is related to values[1], ...{"timestamps":...

View Article

Nested Json invocation

I have a jq script like this:jq -s 'add' \< ./tmp/dispatch_03494ecb-9f72-3233-b4dc-173aa725dc24.json \< ./tmp/dispatch_03494ecb-9f72-3233-b4dc-173aa725dc24_acknowledgement.json | \ jq '{ success:...

View Article

In JQ how to safely process optionally null values

I have this JSON:[ {"alert_timestamp": "2024-10-23T08:49:08Z","odin_timestamp": "2024-10-23T08:50:10Z","alert_url": null,"comments": null,"owner": null,"updated_date": null,"clear_timestamp":...

View Article

Change the value of a path inside an existing json file

I am currently trying to adapt the paths used in one of my project to be used in any OS. Those paths are inside a JSON file (package.json), the parts I want to modify are the keys build and start...

View Article


Using if-then-else-end in jq to handle missing values

This is the command I use to pull the info I need:.results | .[] | {id, name: .general.name, platform: .general.platform, site: .general.site.name, ea_site: .extensionAttributes.[] |...

View Article

How to convert a json response into yaml in bash

I read data from a json file with jq. I wanna append the results into a yaml file, but I dont get it working. I am quite new to shell programming. My goal is to append that "users" to an existing...

View Article


How to use miller mlr or jq to combine two JSON arrays into one array?

I used to be a jq masochist, but I discovered mlr, which seems to offer the opportunity for more (yet different) pain.I found a nice web site that allows me to issue curl commands without API keys,...

View Article

While Loop Read and JQ, use array list of column names

I want to pass a "array" to the while loop so I don't have to repeat the column namesCOLUMNS=("SOURCE_FILE" "EXIF_CONTAINER" "EXIF_CODEC" "EXIF_ENCODER")while IFS=',' read -r SOURCE_FILE EXIF_CONTAINER...

View Article


Using jq with Jenkins pipeline

In my use case i'm running a pipeline which calls aws cli via the withAWS plugin. I use jq to get the needed data, Now the sh returns the output as String. How do i convert this output to json object...

View Article

in jq, how to merge an array of object into 1 object with an array of values

Let's say I have this json:[ {"first": 12355,"second": "abc" }, {"first": 89010,"second": "def" }, {"first": 23423,"second": "hij" }, {"first": 23456,"second": "klm" }, {"first": 11111,"second": "nop"...

View Article

Eliminate items from multiple element arrays based on partial matches to...

Given the JSON below, I am struggling for a jq query that will eliminate any items in places[].fThings[] or places.sThings[] that are not a partial string match to any of the strings found in toDo[]....

View Article
Browsing all 524 articles
Browse latest View live