jq parse string array and string object
I have this json string:json_string="{\"emailRecipients\":\"['test@example.com', 'tes2t@example.com', 'test3@example.com']\", \"anotherEmails\":\"{'test1': 'test1@example.com', 'test2':...
View ArticleHow to assign field name in jq based on a try catch?
I have a json like this:{"a.json": "....", ....}The "..." can be either a json string (The fromjson can decode it then) or it is something else, then it fails.I want a jq filter that outputs if json...
View ArticleFinding if each element of array 1 exists in array 2
I have 2 json files: a_names.json and b_names.json.File a:{"Names": ["a","b","c"]}File b:{"Names": ["b","c"]}What i tried to do was (say i have a loop with counter ascending from 0):a_names.Names |...
View ArticleHow to run jq from gitbash in windows?
I have gitbash in Windows. I am trying to run jq but its giving me error.$ ./jq-win64.exe jq parse error: Invalid numeric literal at line 2, column 0Intention: I want to use jq to parse json.
View ArticleCurl list of links and save files according to URL hierarchy
From the first API call, a JSON response is returned which includes a bunch of links. I want to curl each link, and download the file to a location based on the last 3 path segments.For example, if the...
View ArticleHow to check if there is a exact match in the jq list
I trying to find a tag that matches a particular image repository in the Docker registry.curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list\result:...
View ArticleHow to check if there is an exact match in the jq list
I am trying to find a tag that matches a particular image repository in the Docker registry.curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list\result:...
View ArticleHow to use jq to return length of filtered array?
My json file is called my_locations.json and contains an array called locations. I want to filter this array by all objects that have keys location.is_shop and location.has_parking_space. I then want...
View Articlearray of records without jq's "slurp"
Edit - I was not clear. My apologies.My customer is producing enormous json-like files, using automation. For this reason they can be enormous; tens of gigabytes or more; I cannot control these files...
View Articleneed jq parse certain text value and get its value [closed]
I have this JSON output from Zabbix.I want to get value for last key , to only match ""name": "Zabbix agent availability", and get its "lastvalue" parameter. I'm unable to get it.Is there any way to do...
View ArticleHow to check if an attribute exists in a json using jq?
Hi I am having a shell script ,the shell script has a variable named RESPONSEI want a to check if the json object has an attribute named "address" is present. Also how to get value of the attribute...
View ArticleReplace specific keys in a deeply embedded json file
I have a json file (origin.json) generated locally, I'd like to replace some keys in this origin.json and generate a remote.json so that I could send it to a remote server following it's endpoint...
View Articlejq: error: tostring/1 is not defined at , line 1:
I have a json array of objects in which I would like to create some string using some values. What I tried was:cat a.json | jq 'map(.id+" "+tostring(.time))'It gives the error:jq: error: tostring/1 is...
View Articlejq merge 2 rows to 1
{"field": "@timestamp","value": "2024-08-20 23:00:13.426"}{"field": "@message","value": "Started-1"}{"field": "@timestamp","value": "2024-08-20 23:00:13.427"}{"field": "@message","value":...
View ArticleHow to filter only the object name using jq/jmespath?
I have the following json:{"hostNamesDisabled": false,"hostingEnvironmentProfile": null,"httpsOnly": true,"hyperV": false,"identity": {"principalId": null,"tenantId": null,"type":...
View ArticleTransform a tree-like json so that single "item" in a list is moved up (from...
I have a json that is like a tree of files or folders like this:{"item": [ {"name": "objects","description": "root f","item": [ {"name": "external","item": [ {"name": "buuu","keep1": {} }, {"name":...
View ArticleJQ issues with comments on Json file
I'm using JQ https://stedolan.github.io/jq/ to work in bash with my json and when I read the json is throwing me an error parse error: Invalid numeric literal at line 2, column 5=Since my json has some...
View ArticleUsing JQ how to find/remove one element in json array and remove that same...
I have a json array of hundreds of objects and each object contains (among many other fields) two arrays like this and a status indicator:"searchMetaData": {"rrStandard": ["XYZ5.1","6.3"],"ccStandard":...
View Articlejq: Calculating a new property in local context nested within identity transform
Example JSON with many properties at various levels elided:{"partitiontable": {"label": "gpt","partitions": [ {"node": "/dev/nvme0n1p1","start": 2048,"size": 204801 }, {"node":...
View ArticleExtract oldest entry from JSON
I'm trying to get a curl response and be able to call it like an object. I've been googling for a while and have seen a lot of answers around jq. I've been trying to make that work but I can't seem to...
View Article