Questions tagged [jq]

17 questions
2
votes
1 answer

Extract element from JSON array with jq

I have the following JSON file inp.json: { "x": 0, "tx": [ { "id": "a", "t" : "t for a" }, { "id": "b", "t": "t for b" } ] } I would like to extract the value of the first occurance of the key "t" within "tx". I tried jq…
user1934428
  • 551
  • 4
  • 6
  • 16
2
votes
2 answers

How can I make youtube-dl return the creator of a playlist?

I can use youtube-dl with the --dump-json option and jq to get the uploader of a video: uploader=$(youtube-dl --dump-json "$video_url" | jq -r '.uploader') Is there a way to get the creator of a playlist in a similar way? youtube-dl -j…
fuumind
  • 403
  • 2
  • 7
  • 15
1
vote
1 answer

Failure to convert JSON to CSV file

I need to extract a particular anti-virus product scan results from a JSON file and list the elements in csv format for further processing. JSON file sample as below: Contents of a file scanresults.json { "scans": { "Bkav": { "detected":…
Sam Chan
  • 11
  • 2
1
vote
1 answer

How do I uninstall a tool that was installed without a package manager on windows via git-bash?

Clarification: So my question is rather general and doesn't address a specific tool, however, my issue came as a consequence of the need to remove the tool jq. I would appreciate a more generic approach to address all tools but if not possible, then…
Eyal Gerber
  • 113
  • 4
1
vote
1 answer

Using jq with xargs

I have a json-file with n users. I need to replace the id-field with a different UUID for each user. After that, I need to make n curl calls with the json as payload. How can I achieve this? My json file: [{ "id": "a3d920e", "name": "Alice", …
sjoblomj
  • 13
  • 1
  • 4
1
vote
1 answer

Change one .json key value with an already existing one using jq

My test.json file contains the 2 keys: { "id": "123", "name": "John" } And I want to achieve something like this: { "id": "John" } where as you can see I change the value of the key id with the value of the key name. I'm guessing I…
Oscar
  • 13
  • 3
1
vote
1 answer

jq and array of two things: key and value

I have this script: curl -sX 'GET' \ 'https://api.coingecko.com/api/v3/exchange_rates' \ -H 'accept: application/json' | jq -rc '.[]|select(.)|keys,(.[].value|tostring)' and the source of the JSON is: { "rates": { "btc": { "name":…
pbies
  • 2,757
  • 3
  • 21
  • 23
1
vote
1 answer

cURL - use specific response header as part of the filename

I am using this bash command to write the json http response body into a file: curl -s "http://some.domain.com/getSomeJson" | jq . | tee someJson.json; But what I really want is something like this: curl -s "http://some.domain.com/getSomeJson" | jq…
kiltek
  • 141
  • 1
  • 10
1
vote
1 answer

Piping from youtube-dl to jq in command substitution

When I run youtube-dl -j "$youtube_url" | jq I get a nice json output. However, when I run json=$(youtube-dl -j "$youtube_url" | jq) then jq prints it's usage page and after that youtube-dl fails with a broken pipe error. The json-variable is…
fuumind
  • 403
  • 2
  • 7
  • 15
1
vote
1 answer

Surround Field from JSON with quotes

I want to change a field in json from number to string format. I create the json output from a dynamical created text file like this: LastUpdate=2019-12-01T13:26:46.388817319+01:00 State=NOT…
Thomas
  • 156
  • 7
1
vote
1 answer

Json Parsing with Jsonpath based on string condition filters

I am fairly new with Jsonpath and am forced to use due to a project dependency. The sample json loooks like this { "people": { "a": {"First":"James", "last": "d"}, "b": {"First":"Jacob", "last": "e"}, "c": {"First":"Jayden", "last":…
ram
  • 11
  • 2
1
vote
2 answers

jq filtering - Cannot index array with string "Score"

I am trying to find person name who has a subject and it score. But i am getting index arrary. jq -r '.[] | select(.result."*value*".Score.English) | {Name: .result."*value*".name, Subject: .result."*value*".Score.English} | @text' test.txt | sed…
ABHi
  • 11
  • 1
  • 3
0
votes
1 answer

Extract element from JSON array in file with jq

I have the following JSON file list.json : [ { "$type": "Profile", "ReferenceId": "6e374d9e-5bbe-4015-acd7-ae6f04de0db5", "Name": " aaa" }, { "$type": "Profile", "ReferenceId": "5c055f82-696b-48c2-9b7f-a540d48fcd19", …
0
votes
1 answer

jq filtering - Cannot index array with string ""value"

I am trying to get the application name and print its corresponding apiDefinition for a specific key which is embedded in the value parameter. I get error "Cannot index array with string" As I am not very good at jq especially the nested json, need…
Rocky M
  • 1
  • 1
  • 2
0
votes
1 answer

Tool jq works differently on windows and Linux?

Below is the file content in Json { "FD_sfdsdf:ClientMasterBaseUrl": "http://example.com", "FD_fsdfs:CommonAPIBaseUrl": "http://example.com", "FD_sdfsadfsdf:Secret": "sdfsdf" } Command: cat fd.json| jq -r 'to_entries[] | "setx \(.key)…
1
2