Quantcast
Browsing all 524 articles
Browse latest View live

how to display specific array of arrays elements matching pattern

I have the following array, with thoushand json elements, like the following[ { "id": 302,"hostname": "laptop857","total_memory": 31722,"total_swap": 92535,"distribution": "22.04","hardware": [...

View Article


using jq to display pretty json and grep at the output to filter values

On linux, i actually use jq associated with a curl command.Something like this.. curl <curl expression> | jqbut my pretty json at output got two many lines.I'd like to filter rows, with something...

View Article


Shell script array element value not working in json post query

I have a some url array like below, Later I want to do some post method for each array element. somehow array element not working, but when I try direct url value its working.# Print the uncommon...

View Article

jq: how to filter an array of objects based on values in an inner array?

Given this input:[ {"Id": "cb94e7a42732b598ad18a8f27454a886c1aa8bbba6167646d8f064cd86191e2b","Names": ["condescending_jones","loving_hoover" ] }, {"Id":...

View Article

How to combine lists on the command line (jq)?

I have two files with JSON lists:File 1[0,1,2]["a", "b", "c"]File 2[3,4,5]["d", "e", "f"]How can I use jq or a similar command line tool to combine the lists in each line? The result from combining the...

View Article


ETCD export as json and decode from base64 all key/values to human readable

Is there any easy command line option to export my entire ETCD database to json file but also decode the keys and values automatically from base64?What I succeeded to the moment is this(example show 1x...

View Article

CSV to JSON using jq

If you have a csv dataset like this:name, age, genderjohn, 20, malejane, 30, femalebob, 25, maleCan you get to this:[ {"name": "john", "age": 20, "gender": "male"}, {"name": "jane", "age": 30,...

View Article

flattening a json file using jq

I would like to flatten a json file in order to meet the needs of a legacy program. I would prefer to use jq for this as I know it is available to me.I have a file something like...

View Article


How to extract a field from each object in an array with jq?

I performed a cURL request to get all the users in our Gitlab server, like this.$ curl -H "Private-Token: a;sldkfja;slkdfj" https://gitlab.domain.com/api/v3/users?active=true > my_file.jsonand (part...

View Article


reading json xml value with jq, not getting full string [duplicate]

I have a file api_definitions.json:{"basePolicy": "<policies><inbound><base /><set-header name=\"X-Common-Header\"...

View Article

Searching through an array

Trying to learn how to think in jq script.Given this data:{"characters": [ { "First": "Fred", "Last": "Weasley" }, { "First": "George", "Last": "Weasley" }, { "First": "Hermione", "Last": "Granger" },...

View Article

Format number in thousands separators with jq json cli

Given {"a": 1234567890}, I want 1,234,567,890 in the result, how this can be done with jq echo '{"a": 1234567890}' | jq '.a | FORMAT?'Thanks for @peak's answer, the solution isecho '{"a": 1234567890}'...

View Article

How to merge 2 json files using jq (deep merge and concat array)

With jq command, I want to merge multiple json files.But I have no idea how to achieve below expectation.a.json{"key1": {"key2": [ 1, 2 ] },"key3": "aaa"}b.json{"key1": {"key2": [ 3, 4, 5 ] },"key4":...

View Article


Using jq to merge arrays inside merged objects

There are multiple questions on this topic already, and they all look closely related:jq merge values of same key into an array? requires knowledge of the keys in each object, as far as I can tell; we...

View Article

Map on conditional produces jq: error Cannot iterate over null (null)

I want to get the minimum value of each nested refpos that's associated with GRCH38.An example .refpos looks like this :[ {"name": "_alt_a5760de0b8c517ac3d2929ec9455ac640b540f5a_0" }, {"name":...

View Article


What's the easiest way to map JSON array values to a dictionary using jq?

How can I make a key value dictionary using jq?If I do: cat api_fm.json | jq -r "[ .[].name, .[].status ]"I...

View Article

using a pipe symbol in a jq command throws an error

I am having a shell script file validation-example.sh , it has the followign contentexpected_template = '{"remoteIds": [ {"remoteId": "","requestsReceived": 1 }, {"remoteId": "","requestsReceived": 1...

View Article


How can i validate a json against a template in jq?

I am having a shell script . in my shell script i have a command that returns the following data as a json .{"remoteIds": [ {"remoteId":...

View Article

Conditional map in jq

Is there a way to use map() in a conditional manner ?My problem is that I am using jq against Github repos.Some repos (e.g. https://api.github.com/repos/containerd/nerdctl/releases) use prerelease flag...

View Article

comparing json object fail in jq

I am having a sample shell script file. In my script file I have a json data in a variable and also i have a file containing json .I want to compare the contents of the file against the variable using...

View Article
Browsing all 524 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>