I have a variable with nested json,
a={
"version": "3.0",
"user": "unknown_unknown",
"dateGenerated": "2020-07-08T11:53:23Z",
"status": "OK",
"data": [
{
"parameter": "t_2m:C",
"coordinates": [
{
"lat": 39.23054,
"lon": 9.11917,
"dates": [
{
"date": "2020-07-08T15:53:23Z",
"value": 25.1
}
]
}
]
}
]
}
Looking for a way to grep the "value" in the nested json (like the one highlighted) in variable a
.
I'am using grep
and jq
but I can't show value, it shows "dates"
(echo $result | grep -Po '"dates":.*?[^\\],.*?[^\\]"'
)
but not just the value.
Any help?
value
? What operating system are you using? Do you have the GNU tools? Does yourgrep
support-o
? And, of so, would something as simple asgrep -oP '(?<=value":)[0-9.]+' <<<"$a"
do?