I have a multi-nested weather dump (Accuweather):I am trying to get an indexed response/array ([0,...]) to sort - json and/or bash of the values. But my queries are only getting numbers-space separated. My queries in the two examples are ok in that they are getting to the correct position in the JSON, and the correct values, but just returning numbers.The same when querying a string value, with or without quotes (-r).
Yes, I suppose I could loop through the output, I am just learning jq and know there must be something I am missing in the query to accomplish this. Help please.
Ex: 1 2 3 4 5 spaces only no '[ ]'
#Query 1:drp=$(cat "$HOME/directory/file" | jq '.DailyForecasts[].Day.RainProbability | .')
JSON: -- The query above works as far as returns the correct value/integer output, this is a partial of 5 array sets. Just only returning digits, so: 1 number number number number, not returning in array form . "Day": {"Icon": 2,"IconPhrase": "Mostly sunny","HasPrecipitation": false,"ShortPhrase": "Mostly sunny and breezy","LongPhrase": "Mostly sunny and breezy","PrecipitationProbability": 1,"ThunderstormProbability": 0,"RainProbability": 1,"SnowProbability": 0,"IceProbability": 0,"Wind": {"Speed": {"Value": 15,"Unit": "mi/h","UnitType": 9 ... } #Query 2:apg=$(cat "$HOME/directory/file" | jq '.DailyForecasts[].AirAndPollen | .[1] | .Value | .')
I've tried to map, etc, number of ways (ex. going for the grass value here).JSON: -- Same description as Query 1: returning 5 values not in array form. 12, next iteration, etc.
"AirAndPollen": [ {"Name": "AirQuality","Value": 44,"Category": "Good","CategoryValue": 1,"Type": "Ozone" }, {"Name": "Grass","Value": 12,"Category": "Moderate","CategoryValue": 2 }, ... ]