diff --git a/FAQ.md b/FAQ.md index 64e1fce..4d81c0f 100644 --- a/FAQ.md +++ b/FAQ.md @@ -14,6 +14,24 @@ 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. +Also, if the input string is constant, the `JsonBuffer` will have to make a copy of it. + +```c++ +// case 1: char array => no duplication => good +char[] json = "{\"hello\":\"world\"}"; +jsonBuffer.parseObject(json); + +// case 2: const char* => duplication => bad +const char* json = "{\"hello\":\"world\"}"; +jsonBuffer.parseObject(json); + +// case 3: String => duplication => bad +String json = "{\"hello\":\"world\"}"; +jsonBuffer.parseObject(json); +``` + +To avoid any duplication, make sure you use an input of type `char*` or `char[]` + ### The first parsing succeeds, why does the next ones fail? This can be due to two causes.