jq: delete element from array
I have this JSON file and want to delete an element from an array:{"address": "localhost","name": "local","vars": {"instances": ["one","two" ] }}I am using this command:jq 'del(.vars.instances[] |...
View ArticleConvert string to json in jq [duplicate]
BackgroundI have a json file that contains a string of json within an object:{"requestType": "POST","response": {"size": 78,"text": "{\"recordID\":123, \"title\":\"Hello World\", \"content\":\"Lorem...
View Articlehow to alter values in a field of a json array with jq?
I would like to assign different values to a same field in a json array using jq command line utility,for example let's take this:myjson='[{"a":1,"b":"john"}, {"a":2, "b":"mark"}]'with the following I...
View Articlejq array filter works locally, but not in a GitHub workflow
I'm using jq to extract an array from a JSON in a GitHub workflow:name: Teston: workflow_dispatch:jobs: test: runs-on: ubuntu-latest steps: - name: Test run: echo $(echo...
View Articlehow to present seconds as duration in jq
I want to display some amount of seconds that correspond to dime duration rather than regular date in some human-readable form. say sth like:[ 30300, 120300, 296700, 31922700, 63458700]and what i would...
View ArticleGet all nested keys and values using jq
I have a json like this{"outer1": {"outer2": {"outer3": {"key1": "value1","key2": "value2" } },"outer4": {"key1": "value1","key2": "value2" } }}I want output to be[outer1.outer2.outer3]key1 =...
View ArticleJSON to CSV using jq or python [closed]
Need help converting this JSON and using a specific element of the Column Dimension as the Column header line in CSV using jqInput JSONyour text{"Columns": [ {"Id": "ItemName","IsEditable": false },...
View ArticleJQ question about parsing dictionaries within lists
I have a json file in the following format{"a": [ [ {"p": "p1-value","d": "d1-value" }, {"p": "p2-value","d": "d2-value" } ], [ {"p": "p3-value","d": "d3-value" } ] ],"z": [ [ {"p": "p1-value","d":...
View ArticleHow to get parent node from JSON?
[Update my question little bit]I have below JSON in a test.json file. And I'm trying to figure out how to get all the root names, who's values are completely dynamic in nature.{"result_set":...
View ArticleMerging two arrays using Jq command
I have the following JSON object that I want to merge. So the scenario is ticketId and requester_id should become an attribute of each objects in componentsByProdTourId array.Here is the input JSON...
View ArticleJSON JQ - filter with two statements
I'm using the below which is working perfectly but I want to add one more variable to the filtering, preferably "contains" as I want to filter this one based on a OS field which contains different...
View Articleyq traverse complex values and convert to json file
I have a complex yaml and want to extract information from it using bash script.The yaml is like:content: images: sha256:4c8b96d4fffdfae29258d94a22ae4ad1fe36139d47288b8960d9958d1e63a9d0: annotations:...
View Articletransforming pvclaims into configmaps using jq
Here is my input:{"apiVersion": "apps/v1","kind": "Deployment","spec": {"template": {"spec": {"containers": [ {"volumeMounts": [ {"mountPath": "/var/www/html","name": "shared" }, {"mountPath":...
View Articlejq: print key and value for each entry in an object
How do I get jq to take json like this:{"host1": { "ip": "10.1.2.3" },"host2": { "ip": "10.1.2.2" },"host3": { "ip": "10.1.18.1" }}and generate this output:host1, 10.1.2.3host2, 10.1.2.2host3,...
View Articlejq split string by a pattern
I have a json object with one of field having values for example "countries-sapi-1.0", "inventory-list-api-1.0-snapshot"Note that the first one has sapi and the other one has api.Using jq, how can i...
View Articlejq: Getting two levels of keys
I have some json data that looks like:{"p": {"d": {"a" : {"r": "foo","g": 1 },"b": {"r": "bar","g": 2 } },"c": {"e": {"r": "baz","g": 1 } }, ... }}I want something like:{"d": [ "a","b" ],"c": ["e" ]}I...
View ArticleExploring json with command lines
Can someone helps me finding out a solution for this problem with a command line?Here's my Json file :{"type": "record","name": "ShelfEx »position,"fields": [ {"name": "shopId","type": {"type":...
View ArticleCan I shell out from a jq custom function [closed]
ContextI have a server which has a bunch of routes which may take a json body as an input and may answer with a json response as an output, and I want to quickly test these routes and various...
View ArticleIn jq, how to select the desired properties at all levels?
It seems a pretty basic need, but I can't find it in the tutorialImagine we got an object like:{"data":[ {"prop1":"a", "prop2":"b", "prop3":"c", "prop4":"d",...
View ArticleWhy does curl return "Usage: curl [options...] Invalid category provided"...
I'm trying to create a POST request in a .sh file that posts some json stored in a variable. After the POST it should store the response of the post for me to check via echo. I'm doing this in a...
View Article