09-06-2023, 12:43 PM
Hi, I want to parse the following json string:
{"Time":"2023-09-06T13:38:56","BME280-76":{"Temperature":28.7,"Humidity":47.9,"DewPoint":16.6,"Pressure":1016.7},"BME280-77":{"Temperature":28.6,"Humidity":92.6,"DewPoint":27.3,"Pressure":1017.0},"PressureUnit":"hPa","TempUnit":"C"}
The first javascript line gives already an error
ERROR: Unexpected identifier 'Time'. Expected ';' after variable declaration.
If I run this:
the error is:
ERROR: Unexpected identifier 'Time'. Expected ')' to end an argument list.
I know I can use the 'Jason to Variable' script tool, but that would require more then 10 scripts to get all the variables.
Any idea?
THX Joe
{"Time":"2023-09-06T13:38:56","BME280-76":{"Temperature":28.7,"Humidity":47.9,"DewPoint":16.6,"Pressure":1016.7},"BME280-77":{"Temperature":28.6,"Humidity":92.6,"DewPoint":27.3,"Pressure":1017.0},"PressureUnit":"hPa","TempUnit":"C"}
The first javascript line gives already an error
Code:
var json = Virtuino.readValue("inputTag"); //Read inputTag value as String.
ERROR: Unexpected identifier 'Time'. Expected ';' after variable declaration.
If I run this:
Code:
const obj = JSON.parse(Virtuino.readValue("inputTag")); //Read inputTag value as String.
the error is:
ERROR: Unexpected identifier 'Time'. Expected ')' to end an argument list.
I know I can use the 'Jason to Variable' script tool, but that would require more then 10 scripts to get all the variables.
Any idea?
THX Joe