Category "jq"

How to convert a json response into yaml in bash

I read data from a json file with jq. I wanna append the results into a yaml file, but I dont get it working. I am quite new to shell programming. My goal is to

Is it possible to include current time stamp in jq command?

I am running a curl rest-api call and try to extra some key/value pairs in UBUNTU. This is my current command: curl ..... | jq -c '{"online": .switches.option

How to install JQ on Mac on the command line?

I need to know the most efficient way of installing JQ on Mac (El Capitan). The code is downloaded to my Mac but I would like to know how I can install and oper

Jq to replace text directly on file (like sed -i)

I have a json file that needs to be updated on a certain condition. Sample json { "Actions" : [ { "value" : "1", "properties" : {

Exporting JSON to environment variables

If I have a JSON like this, { "hello1": "world1", "testk": "testv" } And I want to export each of these key-value pairs as environment variables, how t

Exporting JSON to environment variables

If I have a JSON like this, { "hello1": "world1", "testk": "testv" } And I want to export each of these key-value pairs as environment variables, how t

Split string into fields in JQ

I have this JSON: {"item":2, "url":"domain/house/23/bedroom"} I'm trying to use jq to obtain this new JSON: {"item":2, "number":"23", "room":"bedroom"} Is it

How to prevent yq removing comments and empty lines?

Here Edit yaml objects in array with yq. Speed up Terminalizer's terminal cast (record) I asked about how to edit yaml with yq. I received the best answer. But

How to extract all (also nested) key names with jq

How can I extract all key names, even in nested objects with jq? For example, I have json: { "a": 1, "b": { "c": 2 } } and I want to get list:

Replace tags in text file using key-value pairs from JSON file

I am trying to write a shell script that can read a json string, decode it to an array and foreach through the array and use the key/value for replacing strings

How to check JSON and add/remove key

I have a JSON file as an export of a nosql database, the sample below is 2 of 1xxx records. { "task": { "id1": { "completed": true,

Using jq to stream, filter large json file and save output as csv

I have a very large json file I would like to stream (using --stream) and filter with jq, then save it as a csv. This is the sample data with two objects: [{"_i

How to merge multiple json files in a directory with jq or any tool?

I am trying to merge all json files in a directory (can be many). I know that if there are only 2 files, I can use jq -s . file1.json file2.json. But when I tri

How to format a bash array as a JSON array

I have a bash array X=("hello world" "goodnight moon") That I want to turn into a json array ["hello world", "goodnight moon"] Is there a good way for me

jq convert to csv with keys to column rows

I have JSON example like this { "server1": { "dhcp-libs": "12:4.2.5-83.el7.centos.1", "perl-Time-Local": "1.2300-2.el7", "kbd-legacy": "1.15.5-15.

How to extract value from json contained in a variable using jq in bash

I am writing a bash script which has a json value stored in a variable now i want to extract the values in that json using Jq. The code used is. json_val={"co

JQ: How To Change A Value in JSON with embedded keys

I have the following JSON that is being returned from an AWS Secret: { "ARN": "MyArn", "Name": "MySecret", "SecretString": "{\"ConnectionString\":\"