CAUTION: SLIPPERY FLOORThe Arduino Library Manager installs the ArduinoJson version 6 by default.
However, using version 5 is highly recommended because version 6 is still in beta stage.
Open the Arduino Library Manager and make sure that ArduinoJson version 5 is installed.
JsonBuffer; size goes back to zero.
Allocated memory is freed in the case of a
This allows to reuse the
StaticJsonBuffer<200> jb; JsonObject& obj1 = jb.parseObject(json1); // we can use obj1 here... jb.clear(); // now obj1 is dangling!!! // ...but we can reuse the JsonBuffer JsonObject& obj2 = jb.parseObject(json2);
Source of memory corruption
Once you called
JsonBuffer::clear(), all the objects and arrays allocated in this buffer become invalid.
If you try to access such a reference (like the
obj1in the example above), you’re likely to crash your device or at least get very unexpected results.
Don’t try to keep the state of your application in a
JsonObject, instead use custom structures.