Arduinojson: JsonObject value becomes null after changing it

Created on 8 Dec 2019  路  3Comments  路  Source: bblanchon/ArduinoJson

Every 3 seconds, i'm sending the below JSON where i change the value for the key 'deviceValue'

`{"GetValueResponse":{"deviceValue":"11","id":"asd"}}

it works at the start then it starts showing null values as shown below

15:43:09.372 -> {"GetValueResponse":{"value":"28","id":"asd"}} 15:43:19.512 ->

{"GetValueResponse":{"deviceValue":"20","id":"asd"}} 15:43:29.629 ->

{"GetValueResponse":{"deviceValue":"24","id":"asd"}} 15:43:39.738 ->

{"GetValueResponse":{"deviceValue":"26","id":null}} 15:43:49.875 ->

{"GetValueResponse":{"deviceValue":null,"id":null}} and the rest is as above

{"GetValueResponse":{"deviceValue":null,"id":null}}

this is the code that i'm using

`StaticJsonDocument<400> getValueJsonRequest;
JsonObject getObject = getValueJsonRequest.createNestedObject("GetValue");

void setup(){
getObject["value"] = String(random(0, 30));
getObject["id"] = id;
getValueJsonRequest.add(getObject);

}

void loop(){
getObject["value"] = String(random(0, 30));
Serial.println(getValueJsonRequest.as());
delay(2000);
}`

question

All 3 comments

Hi @HilalAH,

Please read:

Best Regards,
Benoit

it worked thanks @bblanchon for your help

You're welcome @HilalAH.
Thank you for using the library.
Don't forget to star the project to show you support ;-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

egadgetjnr picture egadgetjnr  路  3Comments

mhazley picture mhazley  路  4Comments

koffienl picture koffienl  路  3Comments

ligantx picture ligantx  路  4Comments

nardev picture nardev  路  5Comments