diff --git a/FAQ.md b/FAQ.md index c0c455f..ee3fd14 100644 --- a/FAQ.md +++ b/FAQ.md @@ -14,6 +14,29 @@ If you're is case 2., you can solve the problem by increasing the size of the `S If you're in case 3., you may have a memory leak, it up to you to find it. You can try to switch to `StaticJsonBuffer` which is more efficient. +### The first parsing succeeds, why the next ones fail? + +This can be due to two causes. + + +##### Cause 1: reuse of `JsonBuffer` + +First, this can happen if you reuse the same `JsonBuffer`, for example: + +```c++ +StaticJsonBuffer<200> jsonBuffer; +for (int i=0; i<10; i++) { + char json[256]; + readJsonFromSomewhere(json, sizeof(json)); + JsonObject& root = jsonBuffer.parse(json); + if (root.success()) { + Serial.println("parseObject() succeeded"); + } else { + Serial.println("parseObject() failed!"); + } +} +``` + ### What are the differences between `StaticJsonBuffer` and `DynamicJsonBuffer`? | `StaticJsonBuffer` | `DynamicJsonBuffer`