From 6d38219e1fa50dbc80b1c566b77ce30401c10fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Wed, 13 Jan 2016 10:31:10 +0100 Subject: [PATCH] Updated FAQ (markdown) --- FAQ.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/FAQ.md b/FAQ.md index c8b4032..f3ccd99 100644 --- a/FAQ.md +++ b/FAQ.md @@ -2,6 +2,26 @@ See [Compatibility issues](Compatibility issues) first. +### Can I parse data from a stream? + +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. + +To parse data from a stream, you'll have to read its content and put it in a `char[]`: + +```c++ +#define MAX_JSON_SIZE 256 + +char json[MAX_SIZE]; +stream.readBytesUntil('\n', json, MAX_JSON_SIZE); +``` + +If this is not acceptable, you should have a look at other libraries, like [aJson](https://github.com/interactive-matter/aJson). + +See issues [#60](https://github.com/bblanchon/ArduinoJson/issues/60), [#119](https://github.com/bblanchon/ArduinoJson/issues/119), [#194](https://github.com/bblanchon/ArduinoJson/issues/194), [#200](https://github.com/bblanchon/ArduinoJson/issues/200). + ### Should I call `parseArray()` or `parseObject()`? This is a very common question as people are often confused when the JSON input contains mixed arrays and objects.