Quantcast
Channel: Active questions tagged jq - Stack Overflow
Browsing all 537 articles
Browse latest View live

extract ca chain that has multiple CA as list from vault using jq and format...

I trying to generate certs uisng vault pki role. How can i create a single file called ca.crt from the wget command output.$ wget --method=POST --header="X-Vault-Namespace: ns" --header="X-Vault-Token:...

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


How to dynamically replace value with jq in bash [duplicate]

I'm trying to get a value from the Json and add it to another field of the same json file. I need to do it in a lot of file so I'm using a loop:for i in $(find . -name \*.txt); do valorAPoner=$(cat $i...

View Article

parse error: Invalid numeric literal at line 2, column 0

i am trying to read for a big json data structure and I get the message: parse error: Invalid numeric literal at line 2, column 0The command that I'm using is the next one: n_rules=$(echo rulebase_list...

View Article

Case-insensitive check in `jq` for equality

I found the following on the govc govmomi github pages, which allows me to search for VMs by MAC address:govc object.collect -json -type m / config.hardware.device \ | jq -r ' . |...

View Article


How to format a JSON string as a table using jq?

Just started out with Bash scripting and stumbled upon jq to work with JSON.I need to transform a JSON string like below to a table for output in the terminal.[{"name": "George","id": 12,"email":...

View Article

Sorting and comparing json files with ./jq

I am trying to compare two long json files with WinMerge by using QueryJSON plugin.Properties in those files are in random order.That parameter for .\jq does work, but nested objects are not...

View Article

How to detect if there is any value which have space inside double quotes...

Sample json data as below:There are multiple lines in a file. Few lines with NOK sample and rest are OK.How to identify such problematic lines which have...

View Article


Can I pass a string variable to jq rather than passing a file?

I want to convert JSON string into an array in bash.The JSON string is passed to the bash script as an argument (it doesn't exist in a file).Is there a way of achieving it without using some temp...

View Article


Issue creating nested object in jq

Im trying to write a JQ function that will take some key/value arguments and format them into a nested object of various data types.If the arg key has a period, then use the period as a delimiter for...

View Article

JQ — Return first element that satisfies a predicate

I have a string like:"The sky is blue."and a JSON file like[ {"id": 1234,"name": "Entry 1","keywords": ["orange","yellow" ] }, {"id": 2345,"name": "Entry 2","keywords": ["red","blue","pink" ] }, {"id":...

View Article

JQ: Select multiple conditions

I have a json and at the moment using select to get only the data which match one condition, I need to filter based on more conditions.For e.g:.[] | select((.processedBarsVolume <= 5) &&...

View Article

Json use jq to parse, read and return true if entry found

Apologies if this is basic but the doc for jq is not so goodi have this json:{"jsonrpc": "2.0","result": [{"hostid": "10084","host": "Zabbix server","interfaces": [{"interfaceid": "1","ip": "127.0.0.1"...

View Article


JQ: Filtering for keys

I'm trying to use the JQ command to filter a json object to selectively extract keys. Here's a sample object that I've placed in file x.txt:{"activities" : {"-KSndgjqvmQkWVKHCpLh" : {"create_device" :...

View Article

Using jq to replace the value of a JSON field is not working correctly

I have a template JSON file like this:[ {"fields": [ {"name": "body_t","value": "TEST" } ],"id": "abc123" }]I need to replace the "value" of the "body_t" (which is set to TEST in the template).jq...

View Article


jq: how do I handle recursion in this case?

I have JSON output as shown below (the output of lsblk, greatly simplified). I need to generate CSV output which shows the name of a disk, together with a list of mount points, if any. I can generate...

View Article

Differnce between linux shell skript and Gitlab shell script [duplicate]

I have a pipeline that always fail with a shell command. This is:response=$(curl -s -u "${HARBOR_SWIO_USER}:${HARBOR_SWIO_PASS}" -H "Accept:application/json" "$URL")#This line will failecho "$response"...

View Article


Is it possible to convert from JSON or YAML to XML using jq/yq/xq

I have managed to successfully convert an XML file to a YAML file using xqIs it possible using the following tools jq, yq, xq, to convert from either YAML or JSON back to an XML format ?Here is a...

View Article

How to put data from CSV to JSON?

I have a CSV containing two "columns" 'User id' and 'email' example:User id,email1234-1234-1234,some@email.address321-1235-44432,anoteher@email.address322136231345,more.email@address.tooAnd a JSON...

View Article

Convert JSON lines to JSON array using jq

Firstly, I'm new to jq, like 1 day new, I'm also new to JSON, I'm an SQL guy so I'm learning fast but can't get my head around this ... so please bear with me.I'm running Windows, using jq v1.5 on...

View Article
Browsing all 537 articles
Browse latest View live


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