diff --git a/FAQ.md b/FAQ.md index 53a9812..14b39fa 100644 --- a/FAQ.md +++ b/FAQ.md @@ -13,6 +13,7 @@ * [How to compute the JSON length?](#how-to-compute-the-json-length) * [How to create complex nested objects?](#how-to-create-complex-nested-objects) * [The first serialization succeeds, why do the next ones fail?](#the-first-serialization-succeeds-why-do-the-next-ones-fail) + * [Why ArduinoJson is slow?](#why-arduinojson-is-slow) * [Part 3 - Deserialization questions](#part-3---deserializationparsing-questions) * [Can I parse data from a stream?](#can-i-parse-data-from-a-stream) * [Should I call `parseArray()` or `parseObject()`?](#should-i-call-parsearray-or-parseobject) @@ -359,7 +360,19 @@ See [The first parsing succeeds, why do the next ones fail?](#the-first-parsing- +### Why ArduinoJson is slow? +First of all, ArduinoJson is **not slow** by itself. It's slow when used in conjunction with the `WifiClient` from the ESP8266 core. + +The problem is that there is no buffer between ArduinoJson and the WifiClient. + +To solve this, either: + +1. Enable the [Nagle algorithm](https://en.wikipedia.org/wiki/Nagle%27s_algorithm) on `WifiClient` by calling `setNoDelay(false)`. +2. Serialize to a buffer and send the whole buffer in one shot. +3. Insert a [BufferedPrint](https://github.com/bblanchon/ArduinoJson/wiki/Bag%20of%20Tricks#buffered-output) proxy between ArduinoJson and `WifiClient`. + +See issue [#166](https://github.com/bblanchon/ArduinoJson/issues/166), [#271](https://github.com/bblanchon/ArduinoJson/issues/271) and [#301](https://github.com/bblanchon/ArduinoJson/issues/301) ## Part 3 - Deserialization/parsing questions