using jq to assign multiple output variables
I am trying to use jq to parse information from the TVDB api. I need to pull a couple of fields and assign the values to variables that I can continue to use in my bash script. I know I can easily...
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 Articlejq: error: syntax error, unexpected IDENT, expecting $end (Unix shell quoting...
cat explorer/connection-profile/test-network.json | jq ".organizations.Org1MSP.adminPrivateKey.path |= 44ab"jq: error: syntax error, unexpected IDENT, expecting $end (Unix shell quoting issues?) at...
View ArticleConverting JSON to CSV using jq with header line
I have a task to convert a JSON file to a CSV with a header at the top. The header has to be in a particular order. So the order of the keys in the JSON file will be in different order than the header...
View ArticleUsing 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 ArticleHow to filter list based on prefix list?
I have a list of hostnames and I want to filter out all hostnames that end in any of a given List of domains. For example for the hostnames...
View ArticleHow do I portably parse a JSON file using libjq?
Consider the following code snippet based on libjq.#include <stdio.h>#include <stdlib.h>#include <jq.h>#include <jv.h>int main(void) { jq_state *jq = jq_init(); if (!jq) {...
View ArticleSelecting parent objects based on nested child properties
I have a JSON document as a result of scanning a DVD. It contains a TitleList array, each entry of which contains a ChapterList array, each entry of which has a Duration object. I want to select a...
View ArticleHow to combine the sequence of objects in jq into one object?
I would like to convert the stream of objects:{"a": "green","b": "white"}{"a": "red","c": "purple"}into one object:{"a": "red","b": "white","c": "purple"}Also, how can I wrap the same sequence into an...
View Articlehow to get list of available ios simulators?
i want to list available ios simulators as in below format ( iOS version should take from JSON key ){"name": "iPhone 5s (11.4)","udid": "FB6B3F7F-E6CD-4F64-8EC4-6C07C86A25C8"}{"name": "iPhone 6 Plus...
View ArticleFilter empty and/or null values with jq
I have a file with jsonlines and would like to find empty values.{"name": "Color TV", "price": "1200", "available": ""}{"name": "DVD player", "price": "200", "color": null}And would like to output...
View ArticleHow to remove double-quotes in jq output for parsing json files in bash?
I'm using jq to parse a JSON file as shown here. However, the results for string values contain the "double-quotes" as expected:$ cat json.txt | jq '.name'"Google"How can I pipe this into another...
View Articleget label value from docker inspect [duplicate]
I had problem to get the value from the map list due to the key has "." inside.docker inspect jenkins Config: { .."Labels": {"com.docker.compose.config-hash":...
View ArticleConvert JSON file to CSV using jq, expanding nested array data in multiple...
I need to convert a JSON file to CSV in a bash script, this a sample file:{"total": 1,"jobs": [ {"deviceData": {"deviceId": "ad7bcba0","name": "Device name","serialNumber": "Serial","productNumber":...
View ArticleHow to convert a string to an integer in a JSON file using jq?
I use jq to transform a complex json object into a tinier one. My query is:jq 'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode: (.value.booking_service_code)}'...
View ArticleHow do I select multiple fields in jq?
My input file is newline delimited JSON (ndjson) looking something like this:{"login": "dmaxfield","id": 7449977, ...}{"login": "dmaxfield","id": 7449977, ...}I can get all the login names with this :...
View ArticleFiltering out JSON properties where keys do not match length
I have JSON that looks like:{"18003432343": ....,"18005553332": ....,"1-3-2025 10:36:41_08941100 AM": ....,"1-3-2025 11:36:41_08941100 AM": ....}I would like to use JQ to filter out all keys where the...
View ArticleConverting JSON to JSONL without losing original object structure
I have JSON that looks like:{"18003432343": {"04:00:25": {....},"12:00:25": {....}, }, "18005553332": {"18:11:25": {....},"23:00:25": {....}, }}If I convert the above to JSONL using:jq -c '.[]'...
View Articlejq function is not defined when actually it is
$ echo '{"a": "A", "b": [{"c": 1}, {"c": 2}]}' | jq '.a as $a | .b | map( . += {"a": $a})'[ {"c": 1,"a": "A" }, {"c": 2,"a": "A" }]but$ echo '{"a": "A", "b": [{"c": 1}, {"c": 2}]}' | jq 'def...
View Articlejq error: "map_with/1 is not defined", even though it is defined [closed]
$ echo '{"a": "A", "b": [{"c": 1}, {"c": 2}]}' | jq '.a as $a | .b | map( . += {"a": $a})'[ {"c": 1,"a": "A" }, {"c": 2,"a": "A" }]but$ echo '{"a": "A", "b": [{"c": 1}, {"c": 2}]}' | jq 'def...
View Article