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 ArticleConvert 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 ArticleJSON 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 ArticleUsing 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 ArticleJQ - 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 Articlejq 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 ArticleHow 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 ArticleHow 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 ArticleHow 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 ArticleJQ 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 ArticleJQ 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 Articlehow 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 Articlehow 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 ArticleHow 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 ArticleHow 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 ArticleParse 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 ArticleQuery/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 ArticleIgnore 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 ArticleHow 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 ArticleHow 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