-1

Any idea how I can parse below kind of json array of objects in NodeMCU.

"[{\"PropertyID\": \"9641\",\"DBPollCount\": 0,\"SampleTime\": \"1969-12-31T19:00:00\"},{\"PropertyID\": \"9641\",\"DBPollCount\": 0,\"SampleTime\": \"1969-12-31T19:00:00\"}]";

Appreciate the help.

bp581
  • 859
  • 1
  • 16
  • 47

1 Answers1

2

Have you tried using the sjson module (specifically the sjson.decode() method)?

local jsonString = '[{\"PropertyID\": \"9641\",\"DBPollCount\": 0,\"SampleTime\": \"1969-12-31T19:00:00\"},{\"PropertyID\": \"9641\",\"DBPollCount\": 0,\"SampleTime\": \"1969-12-31T19:00:00\"}]'
local jsonObj = sjson.decode(jsonString)

Should do the trick.

xLarry
  • 181
  • 1
  • 4