jq equivalent in python
cat * | jq '.cis[].properties.cloud_vm_display_name' | grep -v null"azuXXXXX""azuXXXXX""azuXXXXXX""azuXXXXXX"Need to extract cloud VM name from multiple json files where the array number is different...
View Articlejq: C:/cygwin64/bin/jq.exe: error while loading shared libraries: ?: cannot...
jq fails with:$ jqC:/cygwin64/bin/jq.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directoryHow can I find out which libary was missing?
View ArticleHow to subtract inner array value from outer array value?
I have the following test.json file:{"now": 1685613599.879,"messages": 1347296469,"aircraft": [ {"hex": "7c806e","type": "adsc","flight": "QF94 ","r": "VH-ZNK","t": "B789","alt_baro": 34000,"gs":...
View ArticlePulling specific data out of JSON via jq to CSV using Bash
I'm working on writing a script to extract specific data from a JSON array and convert it into a CSV. I'm retrieving the data from an API with data that looks like this:{"data": [ {"id":...
View ArticleCombine an arbitrary number of JSON files with jq
I can combine 2 json files using jq, thus:jq -s '.[0] * .[1]' file1.json file2.json >merged.jsonI can combine an arbitrary number of json files by using a loop and on the second and subsequent...
View Articlejq: how to extract a value without a property name
I am trying to get values out of a json file. However, my file has a value without a property name.The json file, names items.json, looks like this:{"AQ_01_Availability": {"class":...
View ArticlePipe aws output to jq will not result in array [duplicate]
I try to use to get all hosts from an elbv2 LoadBalancer rule to an array to expand the list.I tried to query the existing hosts inside the rule withTESTOUTPUT=$(aws elbv2 describe-rules --rule-arns...
View ArticleHow to recursively print the path of all keys in jq
I'd like to get a list of all paths available in a JSON document.There are variations of this question like 'all paths matching a given pattern' or 'print paths plus value'. This question is about the...
View Articlejq: selecting a subset of keys from an object
Given an input json string of keys from an array, return an object with only the entries that had keys in the original object and in the input array.I have a solution but I think that it isn't elegant...
View ArticleHow 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"Operation Not Permitted" - Cannot get read access from App created with...
I am stuck trying to access this specific file from an App I have created with Automator. When the exact same Bash script is run from Terminal, all is dandy. I have checked permissions on the file and...
View ArticleHow to add dependencies into package.json with jq
I want to add package dependencies to the package.json file by bash script using jq.Add new element to existing JSON array with jqHere is the test script with 5 steps:#!/bin/bashadd_element_with_jq() {...
View ArticleUsing backreference as replacement string in JQ
Assuming I want to extract the time part of a date/time string on the shell I can do something like:echo "2021-06-10T10:42:30.016+0200" | sed 's|.*T\(.*\)\..*|\1|g'This returns10:42:30How can I achieve...
View ArticleConditional statement in yq parser for updating script
I m trying to replace a string value in a yaml file and I m not able to get the if working.YAML fileapiVersion: kots.io/v1beta1kind: Configmetadata: name: enterprisespec: groups: - name:...
View Articlejq - Get objects with latest date
Json looks like this:cat test.json |jq -r ".nodes[].run_data" { "id": "1234", "status": "PASSED","penultimate_status": "PASSED", "end_time":"2022-02-28T09:50:05Z" } {"id": "4321", "status": "PASSED",...
View Articleextracting fields from HAR file
On any Chromium-based browser, you can use the More Tools > Developer Tools: "Network" tab option to filter the GET requests, preserve the network log as you scroll down the page to get all hits and...
View ArticleHandle mixed charsets in the same json file
Given I have the following file:{"title": {"ger": "Komödie" (utf8, encoded as c3 b6) },"files": [ {"filename": "Kom�die" (latin1, encoded as f6) } ]}(might look differently if you try to copy-paste...
View ArticleHow to get max value from JSON?
There is a json file like this:[{"createdAt": 1548729542000,"platform": "foo"},{"createdAt": 1548759398000,"platform": "foo"},{"createdAt": 1548912360000,"platform": "foo"},{"createdAt":...
View ArticleAzureDevops passing $`` instead of $() into jq arg via taskgroup
I currently have the following in my taskgroup bash scriptjq --argjson timestamp "$`date +%s`" '.common |= . + {"TimeValue": $timestamp }' ${service}/${env}.json > tmpfile && mv tmpfile...
View ArticleJQ error when trying to parse JSON string - unexpected '['
When trying to query a JSON str, using the script below, I get an error.db_secret_data=$(aws secretsmanager get-secret-value --secret-id "$db_secret_name" --output json)echo...
View Article