Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JSON parsing
#1
Hello Ilias
I have my json parsing well with message having only one level
Example :
{
  "Battery": 100,
  "LastUpdate": "2023-02-03 19:11:39",
  "RSSI": 5,
  "description": "",
  "dtype": "Temp + Humidity",
}


But I dont know how to fill the JSON path when there are more that one level

Example (how to reach the fourh line Temperature) :
{
  "Time": "2023-02-04T19:37:20",
  "ATC087c2e": {
    "mac": "a4c138087c2e",
    "Temperature": 22.8,
    "Humidity": 43,
    "DewPoint": 9.5,
    "Battery": 43,
    "RSSI": -96
  "Time": "2023-02-04T19:37:28",
  "Switch1": "ON",
  "Switch2": "ON",
  "ENERGY": {
    "TotalStartTime": "2022-04-10T21:05:51",
    "Total": 0,
    "Yesterday": 0,
    "Today": 0,
    "Period": [
      0,
      0
    ],
    "Power": [
      0,
      0
    ],
    "ApparentPower": [
      0,
      0
    ],
    "ReactivePower": [
      0,
      0
    ],
    "Factor": [
      0,
      0
    ],
    "Voltage": 228,
    "Current": [
      0,
      0
    ],
    "BL09XX": {
      "Temperature": 36.2
    }
  },
  "ATC2da007": {
    "mac": "a4c1382da007",
    "Temperature": 22.8,
    "Humidity": 42,
    "DewPoint": 9.2,
    "Battery": 64,
    "RSSI": -91
  },
  "TempUnit": "C"
}
Thanks for your help
Reply
#2
Hi,
try this syntax for Json inside json

ATC087c2e/Temperature

for the array inside Json:
ENERGY/Period[1]

Other examples

sensors/temperature/date
sensors/device[1]/temperature/

for the last value of an array
sensors/device/value[10000]/timestamp

for json inside array in root
[2]/temperature
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)