diff --git a/FAQ.md b/FAQ.md index 375315e..943f180 100644 --- a/FAQ.md +++ b/FAQ.md @@ -9,6 +9,17 @@ No. This is a fundamental design principle in this library. The JSON input must be in memory and must be mutable (ie not readonly) to allow zero-copy and zero-allocation, which is *the* strength of this library. +Let's see an example to understand why this is important: + +```c++ +char json[] = "{\"hello\":\"world\"}"; +JsonObject& root = jsonBuffer.parseObject(json); +const char* world = root["hello"]; +``` + +After executing the lines above, the variable `world` will point to the word `"world"` inside the `json` string. During the call to `parseObject()`, the `json` string has been modified to insert the necessary zero-terminator (`\0`), to cut the string `world`. +As you can see this process requires neither duplication nor allocation, but imposes the input to be stored in a `char[]`. + To parse data from a stream, you'll have to read its content and put it in a `char[]`: ```c++