I'm stuck trying to figure out the correct format to read the values from JSON data in powershell.
Input JSON
{
"last_time": "2020-01-13T16:39:37.000Z",
"sensors": {
"1929": [{
"observed": "2020-01-13T16:38:39.000Z",
"humidity": 26.26,
"temperature": 66.55
}],
"2032": [{
"observed": "2020-01-13T16:38:50.000Z",
"humidity": 22.87,
"temperature": 74.6
}],
"2198": [{
"observed": "2020-01-13T16:39:37.000Z",
"humidity": 31.14,
"temperature": 62.79
}]
},
"truncated": false,
"status": "OK",
"total_samples": 3,
"total_sensors": 3
}
Desired Output
<prtg><result><channel>2198 temperature</channel><value>62.79</value></result></prtg>
I can work out the conversion to XML just fine, but i have been banging my head trying to sort out how to read the actual property value in powershell when the key is all numeric in quotes.
I've tried things like:
write-Output $sp.sensors.2198[0].temperature
How does one escape the 2198?