diff --git a/FAQ.md b/FAQ.md index dd5f4d5..f1ee913 100644 --- a/FAQ.md +++ b/FAQ.md @@ -64,11 +64,20 @@ The parsing functions, `parseArray()` and `parseObject()`, may fail for 3 reason 1. The input is not a valid JSON 2. The `StaticJsonBuffer` is too small -3. The `DynamicJsonBuffer` fails to allocate memory +3. The `StaticJsonBuffer` is too big (stack overflow) +4. The `DynamicJsonBuffer` fails to allocate memory -If you're is case 2., you can solve the problem by increasing the size of the `StaticJsonBuffer`or by switching to a `DynamicJsonBuffer`. +Case 1. seems obvious, but a lot of issues are caused by from an invalid input. +In particular, if you're writing an HTTP client, you need to skip the HTTP headers and send only the JSON payload to ArduinoJson. +See issues [#108](https://github.com/bblanchon/ArduinoJson/issues/108), [#167](https://github.com/bblanchon/ArduinoJson/issues/167), [#218](https://github.com/bblanchon/ArduinoJson/issues/218) and [#237](https://github.com/bblanchon/ArduinoJson/issues/237) -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. +If you're in case 2., you can solve the problem by increasing the size of the `StaticJsonBuffer` or by switching to a `DynamicJsonBuffer`. +See issues [#53](https://github.com/bblanchon/ArduinoJson/issues/53), [#89](https://github.com/bblanchon/ArduinoJson/issues/89) and [#202](https://github.com/bblanchon/ArduinoJson/issues/202). + +If you're in case 3., you can try to switch to a `DynamicJsonBuffer`. Indeed, most platforms have a fixed size of the stack (usually 4KB on the ESP8266) the rest of the RAM being reserved to the heap. That's why moving the `JsonBuffer` from the stack to the heap can solve this kind of problem. +See issues [#167](https://github.com/bblanchon/ArduinoJson/issues/167) and [#234](https://github.com/bblanchon/ArduinoJson/issues/234). + +If you're in case 4., you may have a memory leak, it up to you to find it. You can try to switch to `StaticJsonBuffer` which is more efficient. Also, if the input string is constant, the `JsonBuffer` will have to make a copy of it. @@ -88,7 +97,7 @@ jsonBuffer.parseObject(json); To avoid any duplication, make sure you use an input of type `char*` or `char[]` -See issues [#53](https://github.com/bblanchon/ArduinoJson/issues/53), [#89](https://github.com/bblanchon/ArduinoJson/issues/89), [#108](https://github.com/bblanchon/ArduinoJson/issues/108), [#153](https://github.com/bblanchon/ArduinoJson/issues/153), [#154](https://github.com/bblanchon/ArduinoJson/issues/154), [#167](https://github.com/bblanchon/ArduinoJson/issues/167), [#168](https://github.com/bblanchon/ArduinoJson/issues/168), [#172](https://github.com/bblanchon/ArduinoJson/issues/172), [#177](https://github.com/bblanchon/ArduinoJson/issues/177), [#179](https://github.com/bblanchon/ArduinoJson/issues/179), [#202](https://github.com/bblanchon/ArduinoJson/issues/202) and [#223](https://github.com/bblanchon/ArduinoJson/issues/223). +See issues [#154](https://github.com/bblanchon/ArduinoJson/issues/154), [#177](https://github.com/bblanchon/ArduinoJson/issues/177), [#179](https://github.com/bblanchon/ArduinoJson/issues/179) and [#223](https://github.com/bblanchon/ArduinoJson/issues/223). ### The first parsing succeeds, why does the next ones fail?