Parsing JSON from Data storage

Hello I receive the JSON as follows:

[
  {
    "degreesC": 18.39599609375,
    "device_id": "test-dev1",
    "humidity": 40.6005859375,
    "raw": "421/dg==",
    "time": "2019-11-11T21:16:31.633569185Z"
  },
  {
    "degreesC": 19.6044921875,
    "device_id": "test-dev1",
    "humidity": 37.98828125,
    "raw": "Rm4Udg==",
    "time": "2019-11-11T21:40:20.87571354Z"
  }
]

How can I parse it I have problems to access because of [ ].
I use var obj = JSON.parse(testi); testi is the JSON above.
But this don’t work when obj.time
Could somebody help me?

It helps if you mention which programming language you are using. We can try to guess based on the line of code but it’s easier if you tell us :wink:

ok sorry i will use Java script.
and blockly if it goes.

var obj = JSON.parse(testi);
console.warn(testi.degreesC)

grafik

Your input is a JSON list parsed into the obj variable.
To access the first item degreesC property:
console.log(obj[0].degreesC)

https://www.w3schools.com/js/js_json_arrays.asp

1 Like

Thanks. Oh no :sob::see_no_evil:. I tried yesterday obj[1].degreesC. And I forgot 0 is first. I didn’t tried it with two objects array I had only one inside. The example json above I never tried. It was too late yesterday.

1 Like

16 posts were split to a new topic: Parsing payload in Python to send from RPi based node