How to control jq error message when input is not valid json?
jq prints error message like the following when the input is invalid.$ jq . <<< "xxx"parse error: Invalid numeric literal at line 2, column 0I want to control what is printed when the input...
View ArticleStore an SVG image in JSON or not?
I do not know if I'm asking in the correct "Stack", but at the moment I seem to be the most appropriate one. Let me also note if I'm wrong, I'll immediately move the question to another Stack.I need to...
View ArticleGithub Actions not recognizing jq with --arg
I have a workflow that looks like the following:name: Site - Build and Deploy FTPon: push: branches: main paths: - 'src/Site/Site/**' workflow_dispatch:jobs: build: runs-on: ubuntu-latest steps: -...
View ArticleUsing jq to parse multilevel json
I'm trying to parse a JSON file that look like this:[ {"date":"date1","results": [ {"field1":"string11","field2":"string12","field3":"string13", },...
View ArticleGet a list of AWS pipelines ready for stage approval
I have 40+ pipelines that I need to approve from dev to QA and then QA to stage. I am working on a script to use AWS CLI commands to do do. I have been able to do that for a single pipeline where I...
View Articlejq - Append element after picking
System Informationjq: 1.7PickFollowing command works correctly as expected:jq 'pick(.id,.title,.webpage_url,.channel,.duration_string,.upload_date)' *.info.json{"id": "uO8Sn0Xch1s","title": "A...
View ArticleJQ - Using a non UTC date field and looking back a certain amount of time
I am trying to write a BASH+jq one liner to only return the entries that are less than 5 minutes old as I am writing automation to only look back 5 minutes (BASH). Using the following JSON:[ {"id":...
View ArticleHow to convert a string to an integer in a JSON file using jq?
I use jq to transform a complex json object into a tinier one. My query is:jq 'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode: (.value.booking_service_code)}'...
View ArticleUnquote JSON data in CLI
I have a script, that returns quoted JSON data, like "{\"F1\":null,\"F2\":\"text\"...How can I evaluate it and return "clear" data to feed it into jq?
View ArticleProcess large JSON stream with jq
I get a very large JSON stream (several GB) from curl and try to process it with jq.The relevant output I want to parse with jq is packed in a document representing the result structure:{"results":[...
View Articlejq string syntax issue
I am using this on my workflow:jq -c '[map(select(.state == "APPROVED")) | .[] .user.login]')But I am getting this error:jq: error (at :4): Cannot index string with string "state"Error: Process...
View ArticleModify/delete nested/selected values with jq and output entire document
I'm migrating between Terraform providers, and to resolve a bug I need to change the tfstate files which are huge JSON blobs. I've distilled the file down to the most basic form, but I'd like to change...
View ArticleUsing JQ to parse timestamp
I am having some difficulty finding my error with JQ parsing this timestamp."time": "2024-05-13 16:43:06.928708".time| strptime("%Y-%m-%d %H:%M:%S.%f")| strftime("%Y")It clearly is not agreeing that I...
View ArticleJQ filter and recompilation data
My data provider sends me data in 2 different structures.Difference in imageValue fieldobject in about grouparray in banner group{"valuesToUpload": [ {"groupId": "about_2","groupTitle": "","fields": [...
View Articlejq read inline string, not from stdin
This can read from a file:jq '.c | fromjson | .id' my_file.jsonthis reads from stdin:echo "$my_json" | jq -r '.field'what if I just want to read from a string like so:jq '.field'"$my_json"how to do that?
View ArticleUsing jq to parse and display multiple fields in a json serially
I have this Json{"users": [ {"first": "Stevie","last": "Wonder" }, {"first": "Michael","last": "Jackson" } ]}Using jq I'd like to display first and last name serially. Like so -Stevie WonderMichael...
View ArticleSorting user-defined array with strings gives wrong order, even when file...
I am querying ElasticSearch and sorting the documents locally in Bash with jq, as sorting in ES is too slow for me.The original purpose is to create a CSV file.But I find the sorting does not work...
View ArticleHow to avoid "Invalid argument type" error when executing a seemingly valid...
I have a file of s3 paths, sources.lst. Contents:["s3://bucket-name/path/to/file0.tif","s3://bucket-name/path/to/file1.tif",]I am attempting to iterate over these s3 paths & download the files. I...
View ArticleCurl JQ filter results where a value starts with string
curl -X GET \ --url "${API_URL_PREFIX}/orgs/${ORG}/repos?type=private&page=${PAGE}&per_page=100" \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" | jq -r...
View ArticleIterate through objects without array
I've got JSON data that looks like this (notice that it's a list of individual objects without wrapping by []). I would like to walk each object using jq but it is not an array of objects. So how can I...
View Article