Hi guys,
I’m trying to move away from ArduinoJson to the built-in parser for JSON.
When I use relatively short json string the parser works as expected. isValid() returns true and I can iterate over the keys. If I use longer json string (1.5kB) the parser silently fails. isValid() just returns false without any details. Electron does not panics. I’m using 2.0.0 firmware.
I’m 100% percent sure the json string is correct. I verified it using a couple of tools.
I hardcoded the json string (it’s escaped properly) into the code and then memcpy into the local buffer.
so it should be possible use JSONValue::parse safely. Are there any limits related to the built-in parser I should be aware of? Docs does not say what’s the maximum length or tokens number.
{"log":[{"level":"info","handler":"particle","facility":"app"},{"level":"info","handler":"serial","facility":"app"},{"level":"warn","handler":"particle","facility":"system"},{"level":"warn","handler":"particle","facility":"system"}],"ss":{"internal":[{"on":1,"name":"Sys.pwr","pt":20,"mt":200,"u":0},{"on":1,"name":"Sys.bat","pt":60},{"on":1,"name":"Sys.rssi","pt":20,"mt":200,"u":0},{"on":1,"name":"Sys.gps","pt":60},{"on":1,"name":"Sys.mem","pt":20,"mt":200,"u":0},{"on":1,"name":"Sys.tmp","pt":60},{"on":1,"name":"Sys.soc","pt":30,"mt":200,"u":0}],"dinputs":[{"name":"S.chn","u":1,"in":0,"mt":500,"pt":60},{"name":"Brn.flr","u":1,"in":1,"mt":500,"pt":60},{"name":"Pmp.flr","u":1,"in":2,"mt":500,"pt":60},{"name":"G.flr","u":1,"in":3,"mt":500,"pt":60},{"u":1,"mt":500,"pt":60,"in":4,"name":"Door"}],"ainputs":[],"vinputs":[{"u":1,"mt":200,"pt":60,"in":0,"name":"VIRT"},{"u":1,"mt":200,"pt":60,"in":1,"name":"NAZWA"}],"doutputs":[],"mbrtu":[{"len":1,"udev":0,"tfunc":0,"targ":1,"f":3,"sid":9,"addr":3180,"u":1,"mt":1000,"pt":120,"name":"SP","rs":485,"type":"int16","targ2":0}]},"alarms":[{"name":"AWARIA2","timeout":0,"autoEnable":0,"on":{"output":{"state":1,"out":0},"conditions":[{"reg":"Brn.flr","op":"eq","v":"1"}]},"off":{"output":{"state":0,"out":0},"conditions":[{"reg":"Brn.flr","op":"ne","v":"1"}]}},{"timeout":0,"autoEnable":1,"on":{"output":{"state":0,"out":1},"conditions":[{"reg":"VIRT","op":"eq","v":"0"}]},"off":{"output":{"state":1,"out":1},"conditions":[{"reg":"VIRT","op":"ne","v":"0"}]},"name":"TEST"}]}```
My electron is a more or less universal measurement device. It means that I have to have option to configure different measurement subsystems (digital inputs, analog inputs, modbus rtu, modbus tcp, pt100 etc.) depending on where my device is installed. Thats the reasoning behind so big json string.