diff --git a/FAQ.md b/FAQ.md index 9865732..b68d98e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -7,6 +7,7 @@ * [How to determine the buffer size?](#how-to-determine-the-buffer-size) * [What are the common sizes for JsonBuffer?](#what-are-the-common-sizes-for-jsonbuffer) * [I found a memory leak in the library!](#i-found-a-memory-leak-in-the-library) + * [Why shouldn't I use a global `JsonBuffer`?](#why-shouldnt-i-use-a-global-jsonbuffer) * [How to reuse a `JsonBuffer`?](#how-to-reuse-a-jsonbuffer) * [What's the best way to use the library?](#whats-the-best-way-to-use-the-library) * [How to write a function that works with both `JsonArray` and `JsonObject`?](#how-to-write-a-function-that-works-with-both-jsonarray-and-jsonobject) @@ -168,10 +169,22 @@ See issues [#72](https://github.com/bblanchon/ArduinoJson/issues/72), [#87](http See [ArduinoJson: Avoiding pitfalls](https://github.com/bblanchon/ArduinoJson/wiki/Avoiding%20pitfalls) and [FAQ: What's the best way to use the library](https://github.com/bblanchon/ArduinoJson/wiki/FAQ#whats-the-best-way-to-use-the-library) +### Why shouldn't I use a global `JsonBuffer`? + +ArduinoJson is designed to do one thing and to do it well: **the JSON serialization**. +It's not a framework that you can use as a backbone of your application. +In particular `JsonObject` and `JsonArray` should not replace your own data structures; that would be terribly inefficient. + +So before trying to use a global `JsonBuffer`, ask yourself first "Am I really using ArduinoJson for serializing, or am I pushing it beyond its initial intent?". + +See also [How to reuse a `JsonBuffer`?](#how-to-reuse-a-jsonbuffer) and [What's the best way to use the library?](#whats-the-best-way-to-use-the-library). + +See issues [#160](https://github.com/bblanchon/ArduinoJson/issues/160), [#203](https://github.com/bblanchon/ArduinoJson/issues/203), [#219](https://github.com/bblanchon/ArduinoJson/issues/219), [#242](https://github.com/bblanchon/ArduinoJson/issues/242), [#243](https://github.com/bblanchon/ArduinoJson/issues/243), [#341](https://github.com/bblanchon/ArduinoJson/issues/341) and [#347](https://github.com/bblanchon/ArduinoJson/issues/347). ### How to reuse a `JsonBuffer`? `StaticJsonBuffer` and `DynamicJsonBuffer` are designed to be throwaway memory pools, they are not intended to be reused. +As a consequence, using a global `JsonBuffer` is almost always a bad idea. If you believe you need to reuse a `JsonBuffer`, it's because [you're not using the library correctly](https://github.com/bblanchon/ArduinoJson/wiki/FAQ#whats-the-best-way-to-use-the-library).