Quantcast
Browsing all 524 articles
Browse latest View live

How can I modify a specific object structure at any location in a larger JSON...

Say I have this JSON:{"lunch": {"time": "11 am","food": {"is_pizza": true } },"snacks": [ {"time": "2 pm","food": {"is_pizza": true } }, {"time": "3:30 pm","food": {"is_pizza": true } } ],"dinner":...

View Article


Convert bash array to json array and insert to file using jq

Given a bash array, how to convert it to a JSON array in order to output to a file with jq?Additionnally: is there a way to keep the server_nohup array unchanged instead of re-writing the whole json...

View Article


JSON Query - 'jq' how do I get / update an object from an array or list

I have the below code in which I need to get/update the values of an object. I am able to get jq -r .settings.tasks What I need is to get and update values of base_parameters under notebook_task and...

View Article

Using jq with bash to run command for each object in array

How can I run a Bash command for every JSON object in a JSON array using jq? So far I have this:cat credentials.json | jq -r '.[] | .user, .date, .email' | mycommand -u {user} -d {date} -e {email}This...

View Article

JQ - create JSON array using bash array with space

I need to use proper bash array to create a JQ array. I can't use , to split since I need to make use of the proper bash array in a forloopI need to create a json array using bash array and pass it to...

View Article


jq equivalent in python

cat * | jq '.cis[].properties.cloud_vm_display_name' | grep -v null"azuXXXXX""azuXXXXX""azuXXXXXX""azuXXXXXX"Need to extract cloud VM name from multiple json files where the array number is different...

View Article

How to Upload JSON Keys to the "metadata" Attribute in the LangChain...

The primary objective of this activity is to display a summarized response alongside the document source in the LangChain QA bot.Within my input JSON data, there are three keys: page_name, page_data,...

View Article

How to update value in json object with key as argument (using `jq`)

Using jq I want to update a value in a json object.The key of the value to be updated is passed as an argument.Input{"a": 1,"b": 2,"c": 3}Expected output with argument: key=b{"a": 1,"b": 42,"c": 3}I...

View Article


How to convert one line JSON to JSONLINES format using jq?

I'm trying to convert a big one line JSON file to a multiline JSONLINES file. I've tried a bunch of commands and none of them are doing what I expect them to. This is the format of my data (input file:...

View Article


JQ extract array id of an object

I have this input data :{"list": {"1": {"attributes": {"content": [],"pageable": {"pageNumber": 0,"pageSize": 10 } } },"2": {"attributes": {"content": [ {"id": "AZER" } ],"pageable": {"pageNumber":...

View Article

JQ works when I run PowerShell through terminal but not when I use cron jobs

I'm working on a PowerShell code using jq inside it.jq -c '.Documents[]' FULL_PATH/input.json > FULL_PATH/output.jsonWhen I directly execute it in terminal the entire program runs without any issues...

View Article

how to parse json parameter file to semicolon separated string

I have this json file for parameters[ {"ParameterKey": "code","ParameterValue": "ab" }, {"ParameterKey": "env","ParameterValue": "prod" }, {"ParameterKey": "api","ParameterValue": "testapi" },...

View Article

how to update each object in a json array using jq

I have an array of objects that looks like this:[ {"host": "1.exampl.com", "path": "/dir1/file.html"}, {"host": "2.exampl.com", "path": "/dir2/file.html"}, {"host": "3.exampl.com", "path":...

View Article


How to select unique JSON objects from Identical JSON array with JQ

Below is the input JSON:{"sn": "fdd","sc": [ {"pn": "di","pv": {"val": "26","com": "=" },"fix": "Hello","tp": "String" }, {"pn": "di2","pv": {"val": "28","com": "=" },"fix": "Hello2","tp": "String" }...

View Article

How to filter elements in a document using another results of another filter?

This may be simpler to explain with an example. Consider the following simple json:[ {"id": 1, "ref":32, "key":10}, {"id": 2, "ref":32, "key":75}, {"id": 3, "ref":27, "key":13}, {"id": 4, "ref":27,...

View Article


Parse json with jq in AWS CLI

I need an output similar to this:{"InstanceType": "c4.xlarge","PrivateIpAddress": "10.54.130.52","PlatformDetails": "Windows BYOL","State":"Name": "running" }}Reading the documentation of the jq...

View Article

Query/update json file where key has multiple dots in name

Given test file: sample.json:{"host_config": {"host1.reg.fqdn.com": {"config1": "AAA","config2": "000"},"host2.reg.fqdn.com": {"config1": "BBB","config2": "000"},"host3.reg.fqdn.com": {"config1":...

View Article


Ignore Unparseable JSON with jq

I'm using jq to parse some of my logs, but some of the log lines can't be parsed for various reasons. Is there a way to have jq ignore those lines? I can't seem to find a solution. I tried to use the...

View Article

How to use json data from an existing object to update an other object?

Here is my first input (recorded as bash var $services){"key": "movies-wikibase-jobrunner","subPath": "LocalSettings.php","cm": "movies-wikibase-jobrunner-localsettings-override-php"}{"key":...

View Article

How to append a new object in an array containing a key in json file with jq...

file.json is as below and i have to add a new tenant entry called "test3" in "tenants" key.{ "lease_id": "", "renewable": false, "lease_duration": 43, "data": { "collections": [ "testlines" ],...

View Article
Browsing all 524 articles
Browse latest View live