diff --git a/FAQ.md b/FAQ.md index 96129e9..90f12e1 100644 --- a/FAQ.md +++ b/FAQ.md @@ -17,6 +17,7 @@ - [Why does the generated JSON contain garbage?](#why-does-the-generated-json-contain-garbage) - [How to compute the JSON length?](#how-to-compute-the-json-length) - [How to create complex nested objects?](#how-to-create-complex-nested-objects) + - [How to insert a `null`?](#how-to-insert-a-null) - [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/parsing questions](#part-3---deserializationparsing-questions) @@ -24,6 +25,11 @@ - [Can I parse data from a stream?](#can-i-parse-data-from-a-stream) - [Can I parse a JSON input that is too big to fit in memory?](#can-i-parse-a-json-input-that-is-too-big-to-fit-in-memory) - [Why parsing fails?](#why-parsing-fails) + - [Case 1: The input is not a valid JSON](#case-1-the-input-is-not-a-valid-json) + - [Case 2: The `StaticJsonBuffer` is too small](#case-2-the-staticjsonbuffer-is-too-small) + - [Case 3: The `StaticJsonBuffer` is too big](#case-3-the-staticjsonbuffer-is-too-big) + - [Case 4: The `DynamicJsonBuffer` fails to allocate memory](#case-4-the-dynamicjsonbuffer-fails-to-allocate-memory) + - [Case 5: You called `parseObject\(\)` instead of `parseArray\(\)`](#case-5-you-called-parseobject-instead-of-parsearray) - [The first parsing succeeds, why do the next ones fail?](#the-first-parsing-succeeds-why-do-the-next-ones-fail) - [Parsing succeeds but I can't read the values!](#parsing-succeeds-but-i-cant-read-the-values) - [How to know the type of a value?](#how-to-know-the-type-of-a-value) @@ -448,7 +454,41 @@ will generate: } ``` -See issues [#51](https://github.com/bblanchon/ArduinoJson/issues/51), [#252](https://github.com/bblanchon/ArduinoJson/issues/252) and [#264](https://github.com/bblanchon/ArduinoJson/issues/264) +See: + +* issues [#51](https://github.com/bblanchon/ArduinoJson/issues/51), [#252](https://github.com/bblanchon/ArduinoJson/issues/252) and [#264](https://github.com/bblanchon/ArduinoJson/issues/264) +* [API Reference: JsonArray::createNestedArray()](https://github.com/bblanchon/ArduinoJson/wiki/API-Reference#jsonarraycreatenestedarray) +* [API Reference: JsonArray::createNestedArray()](https://github.com/bblanchon/ArduinoJson/wiki/API-Reference#jsonarraycreatenestedarray) +* [API Reference: JsonObject::createNestedArray()](https://github.com/bblanchon/ArduinoJson/wiki/API-Reference#jsonobjectcreatenestedarray) +* [API Reference: JsonObject::createNestedObject()](https://github.com/bblanchon/ArduinoJson/wiki/API-Reference#jsonobjectcreatenestedobject) + + +### How to insert a `null`? + +There are two ways to serialize a `null`: + +* either set the value to `(char*)0`, +* or set the value to `RawJson("null")` + +For example, to generate the following JSON: + +```json +{"myValue":null} +``` + +you can write: + +```c++ +DynamicJsonBuffer jsonBuffer; +JsonObject& root = jsonBuffer.createObject(); +root["myValue"] = (char*)0; // or (char*)NULL if you prefer +root.printTo(Serial); +``` + +See: + +* issue [#418](https://github.com/bblanchon/ArduinoJson/issues/418) + ### The first serialization succeeds, why do the next ones fail?