Edit a json file with batch file or command prompt [closed]
I have a json file for some conversation with the user and an ai assistant,{ "model": "meta-llama/llama-4-scout-17b-16e-instruct", "messages": [ { "role": "system", "content": "You are Julia, and you...
View ArticleJQ select NOT IN does not return correct data
DATA:[ {"NetworkInterfaces": [ {"NetworkInterfaceId": "eni-1" }, {"NetworkInterfaceId": "eni-2" } ],"InstanceId": "i-1" }, {"NetworkInterfaces": [ {"NetworkInterfaceId": "eni-3" },...
View ArticleHow to add and combine objects in jq
I want to use jq to add new objects into the following JSON string.Here is the test json_string:json_string="$(cat <<'END'{"hello": {"foo": {"version": "1.1.1" } },"world": {"bar": {"version":...
View Articlejq how to create a dynamic select list
I'm wondering how you can I create a dynamic select statement to be used with jq. I want to be able to search a result based on names of people that I provide to my script....
View ArticlePossible to use has() with nested keys?
Is it possible to use the jq has() function with nested keys?jq -r -c 'has("a.b")'<<< '{"a":{"b":"hello"}}'this returns false, I have also triedhas("a|b")has("a[b]")
View ArticleHow to add array from object's keys in jq
I want to add bundleDependencies from the dependencies's keys by using jq.json_string="$(cat <<'END'{"name": "hello","dependencies": {"progress": "^2.0.0","tar": "^6.2.1" }}END)"Here is the...
View ArticleHow to clear all object keys's value in jq
I want to clear all values from "dependencies" by using jq:json_string="$(cat <<'END'{"name": "hello","dependencies": {"progress": "^2.0.0","tar": "^6.2.1" }}END)"Here is the expected...
View ArticleHow do I use an element in a subfunction?
I'm trying to use the sub function to search/replace, but using JSON elements rather than literals.Here's a simple example JSON:{"example": {"search_for":...
View ArticleGet unique objects and arrays based on key value
Is there a way to return a unique object/array when duplicates exist? Here's what I'm trying to do.I have a payload like this:{"data": [ {"account":...
View ArticleRemove duplicates from JSON arrays
I want to remove the duplicates from each array in this JSON:{"abc": ["five" ],"pqr": ["one","one","two","two","three","three","four","four" ],"xyz": ["one","one","two","two","four" ]}Output I am...
View ArticleRemove Duplicate Array Values
I am using the following jq query to extract the AWS ARN and associated protocols. However I only need the ARN to be listed once followed by the ports and protocolsmy code is jq -r '.Listeners[] |...
View ArticleHow to ignore duplicated array items in jq
I want to set bundleDependencies by using jq:json_string="$(cat <<'END'{"name": "hello","dependencies": {"progress": "^2.0.0","tar": "^6.2.1" },"devDependencies": {"node-fetch": "~2.6.1","yargs":...
View ArticleJQ can't parse \u2022 character
I'm trying to perform a bulk upload to Elasticsearch (around 1mln documents). In order to do that, I'm using jq to reformat the JSON file extracted from MySQL database and curl to post the data to...
View ArticleJq create object fails when key is missing
I have two example filesexample1:{"label": "Example1","attributes": [ {"objectTypeAttribute": {"name": "Created"},"objectAttributeValues": [ {"value": "create time 1" } ] }, {"objectTypeAttribute":...
View ArticleInstall jq JSON processor on Ubuntu 10.04
Is there a way to install jq JSON processor on Ubuntu 10.04?I Tried the usual sudo apt-get install jq but got the error E: Couldn't find package jq
View ArticleHow to sort this json file with either jq or sed
{"adfdasfdafdfds": {"amount": 43,"mints": ["adfdasffd","dsafdsafdsfds" ] },"dfsfsdfdsf": {"amount": 1020,"mints": ["dfsfsads" ] },"sdfsdfdfgf": {"amount": 1,"mints": ["fsfdsfdfds" ]How to sort this...
View ArticleHow to exclude a particular subtree from processing descendants in jq
I have the following json input:{"to_exclude": {"x": "something","aa": {"x": "something","aaa": {"x": "something" } } },"a": {"x": "something else","aa": {"x": "something else","aaa": {"x": "something...
View ArticleJQ: How to convert a very nested JSON file (tree like), in CSV with same key...
I have a PDF bookmark structure (tree like), which looks like this:Content Author 1 Piece 1 Piece 2 Author 2 Piece 3 Piece 4 Movement 1 Movement 2 Movement 3 Piece 5Using qpdf, it could be formatted in...
View ArticleApply jq functions conditionally to matching and non-matching JSON subtrees
I want to apply one function to all descendants of a particular node in a tree, and a different function to all other nodes, in the following way:if path_matches(.deep.path.matching) then...
View ArticlePass parameterized functions as callbacks to `jq` function
I'd like to dynamically pass parameterized processing functions as callbacks to a selective traversing function (process_matching_and_others).In the example below, that's based on this excellent answer...
View Article