How to get jq to output a long dataset (part 2)?
Suppose I have this ndjson file:{"id": 99, "labeled_values": [["one", "green"], ["two", "red"], ["three", "blue"]]}{"id": 100, "labeled_values": [["four", "green"], ["five", "red"]]}How do I get the...
View ArticleHow to make a certain double cartesian product with jq?
Suppose I have this dataset:{"id": 99, "labeled_values": [["one", "green"], ["two", "red"], ["three", "blue"]], "flavors": ["hot", "cold"]}{"id": 100, "labeled_values": [["four", "green"], ["five",...
View ArticleWhat is jq '.key["value"]'?
jq '.key["value"]' config.json is found in some of our bash scripts and when I tested it, it seems to be doing the same thing that jq '.key.value' config.json does. So I am not sure why the latter...
View Articleget the first (or n'th) element in a jq json parsing
I can get the 1st element in a json inside []$ echo '[{"a":"x", "b":true}, {"a":"XML", "b":false}]' | jq '.[1]'{"a": "XML","b": false}But if the json is already disassembled (for instance, after...
View ArticleHow to get the name of the enclosing object while filtering for property...
I have a JSON file that looks like this:{"somename": {"prop1": "https://xxxx","prop2": "xxxx","prop3": false },"anothername": {"prop1": "https://yyyy","prop2": "yyyy","prop3": false },"fubar":...
View ArticleUsing jq to get traffic total from vnstat [closed]
Can this be simplified?begin=$( date -d "-3 days" +%s )totalMB=$( vnstat -i eth0 --json | jq -r ".interfaces[0].traffic.fiveminute" | jq -r ".[] | select( .timestamp >= $begin ) | {\"t\": [.rx, .tx]...
View ArticleHow to use jq to output JSONL (one independent JSON object per line)
My request sounds trivial but I could not find a way to do it. I have as input an array of JSON objects:[ {"foo": 1,"bar": 2 }, {"foo": 3,"bar": 4 }, (...)]and I want as output the JSONL version of the...
View Articlejq array filter works locally, but not in a GitHub workflow
I'm using jq to extract an array from a JSON in a GitHub workflow:name: Teston: workflow_dispatch:jobs: test: runs-on: ubuntu-latest steps: - name: Test run: echo $(echo...
View ArticleCan 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 ArticleHow to pad numbers with JQ?
I'd like to add leading/trailing zeros to strings from numbers — resultant string needs to contain "01" or "001" and not "1". I noticed project https://github.com/joelpurra/jq-zeros but I have jq...
View ArticleHow to sort a json file by keys and values of those keys in jq
We're building a website using the Pentaho CTools library, which has a graphical dashboard editor which writes out JSON-format files for part of the dashboard.I'd like to apply a transform to these...
View ArticleWhich IDEs support development in jq?
I am using IntelliJ as an IDE.Unfortunately, IntelliJ does not support jq.Language injection is not offered and I can't find a suitable plugin.I searched for "IDE support for jq" or similar many times...
View Articlestuck parsing a json object, to extract "key/value" pairs
I have an application that generates data in this form:[ {"metadata": {"labels": {"team": "eng" } },"spec": {"labels": {"instance_id": {"result": "x387j" },"another_field": {"result": "dfsf" } } } },...
View ArticleEdit JSON property file for use in bash script
I have a .sh script and a .json properties file for use with AWS CLI v2 to create a CF Stack. I have a parameters file in JSON that I need to substitute one value, but all th key/value pairs are the...
View ArticleAdd key:value pairs to JSON object in Bash
I would like to add a number of key:value pairs to an existing JSON string. The values are passed as command line arguments to my script.So far I've got thisdata='{"update": { "labels": [] } }'for...
View Articlejq : Generate UUID in field
I have a requirement to tag records uniquely with UUIDs (for a correlation id). I cant see a direct way to do this via the options, is such a thing possible? If not, is there some kind of workaround...
View ArticleHow to convert GMT to GMT + 09(KST) from jq result
jq result is below.{date = 2024-06-07 00:00:00}That is GMT.How do I change timezone GMT+09(KST)?Regards.
View Articlegcloud publish Pub/Sub JSON message where JSON properties contain space...
I have a JSON file named countries/list.json I want to publish the content with gcloud CLI.{"countries": [ {"id": "SE","name": "Sweden" }, {"id": "UK","name": "United Kingdom" } ]}Accoring to the CLI...
View ArticleUnable to pip install jq on Windows
I wrote this code in Python(using Langchain) in order to load different types of documents and retrieve a proper ai answer related to a question asked before. It was working okay until I decided that I...
View Article"pip install jq" generates errors on Mac and Windows
Duplicate of this issue, but the first answer there is wrong (jq is supported on Windows) and the second refers to brew so I'm guessing is for Mac.WindowsI am trying to install jq for python from the...
View Article