Hi all, I’m trying to wrap my head around how to pull individual values out of some parsed Jason which I’m getting from a node-js pool controller running on a Rasberry Pi. I’ve looked at some of the other topics and tried my way in the evaluation console to get anything out, yet no luck so far.
This is what the json looks like in Firefox/raw/prettyprint:
(If you’re wondering what the “1” is for in the 3rd line, it’s the pump number, as the pool controller supports multiple pump units)
{
“pump”: {
“1”: {
“pump”: 1,
“name”: “Pump 1”,
“type”: “VS”,
“time”: “9:55 PM”,
“run”: 4,
“mode”: 0,
“drivestate”: 0,
“watts”: 0,
“rpm”: 0,
“gpm”: 0,
“ppc”: 0,
“err”: 0,
“timer”: 0,
“duration”: 0,
“currentrunning”: {
“mode”: “off”,
“value”: 0,
“remainingduration”: -1
},
“externalProgram”: {
“1”: 750,
“2”: 1500,
“3”: 2900,
“4”: 3450
},
“remotecontrol”: 1,
“power”: 0,
“friendlyName”: “Pump 1”,
“virtualController”: “enabled”,
“currentprogram”: 0
}
}
}
I read somewhere that one need to escape the curly brackets, so I did that with this fugly hack:
which yields this:
So this is the essence of the piston, i can post it yet it doesn’t really say much more than what’s below:
Make a GET request to (my url)
Set variable {pumpData} = {$response}
Set variable {parsable_variable} = replace({pumpData}, hacky string from above)
Do parse Json data {parseable_variable}
So if I understand it right, my parsable_variable here should now be, well - parsable?
I’ve tried all sorts of things I’ve found in the forums, yet I can’t seem to nail down the right incantation to pull out the values? Some of my fails:
set variable time = parsable_variable.pump.1.time
set variable time = parsable_variable.pump.[0].pump.[0].1.[0]
array item??
I’d be really happy if someone could kick me in the right direction and show me the correct syntax for an expression to pull out individual values from the structure above.
Thanks!