I'm having issues querying over this json
{
"cars":{
"dfhuidsfiusd":{
"name":"Mercedes",
details: {
"plate_number":"sas2-hd-3",
"year": 2009
}
},
"uiwouiouss":{
"name":"Jaguar",
details: {
"plate_number":"sas2-hd-3",
"year": 2009
},
},
"sdikdshkjsd":{
"name":"Toyota",
details: {
"plate_number":"sas2-hd-3",
"year": 2009
}
}
}
}
To get elements in the details object i need to pass through these random values which could change.
I decided to go with this library https://github.com/tidwall/gjson code :
result := gjson.Get(json, `cars.#.details(year="2009")`)
println(result.String())
Since they all value year=2009 in common, I am expecting the following output:
dfhuidsfiusd
sdikdshkjsd
uiwouiouss
But it's just prints empty
Putting these random values in an array and iterating might work, but I want to assume these values are not known beforehand, thanks.