Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse json in javascript
#1
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


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
Reply


Messages In This Thread
Parse json in javascript - by Joe - 09-06-2023, 12:43 PM
RE: Parse json in javascript - by Joe - 09-12-2023, 07:37 AM
RE: Parse json in javascript - by iliaslamprou - 09-12-2023, 09:41 PM
RE: Parse json in javascript - by Joe - 09-13-2023, 07:04 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)