Parsing JSON help #834
Unanswered
JamieCoupe
asked this question in
Q&A
Replies: 2 comments
-
I couldn't figure it out but setting the parser to backend and changing the |
Beta Was this translation helpful? Give feedback.
0 replies
-
parse-json |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm trying to parse the UK Energy source mix into a table for some reporting. The data looks like this:
{ "data": [ { "regionid": 16, "dnoregion": "Scotland", "shortname": "Scotland", "data": [ { "from": "2024-05-03T12:00Z", "to": "2024-05-03T12:30Z", "intensity": { "forecast": 19, "index": "very low" }, "generationmix": [ { "fuel": "biomass", "perc": 0.1 }, { "fuel": "coal", "perc": 0 }, { "fuel": "imports", "perc": 0 }, { "fuel": "gas", "perc": 4.7 }, { "fuel": "nuclear", "perc": 14 }, { "fuel": "other", "perc": 0 }, { "fuel": "hydro", "perc": 2.2 }, { "fuel": "solar", "perc": 5.1 }, { "fuel": "wind", "perc": 73.8 } ] } ] } ] }
I'm having difficulties parsing it using infinity + UQL mv-expand. I'm trying to convert the generationmix data to a table that will look like:
| Fuel | Perc |
| coal | 0.1 |
| biomass | 0.2 |
...
I've tried this (similar to the post here https://community.grafana.com/t/how-to-read-arrays-from-json-using-infinity-datasource-plugin/57028)
parse-json | scope "data" | mv-expand "generation_mix"="generationmix" | project "fuel"="generation_mix.fuel" "perc"="generation_mix.perc"
but I cant seem to get that working, I think I might be parsing the JSON wrong but I'm new to UQL, can anyone spot where I'm going wrong?
Beta Was this translation helpful? Give feedback.
All reactions