From 35d581d6e404e2ebd8670c9643ce890fafadf08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Sat, 9 Jul 2016 18:42:25 +0200 Subject: [PATCH] Updated API Reference (markdown) --- API-Reference.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/API-Reference.md b/API-Reference.md index e0d84d1..5b6b8e6 100644 --- a/API-Reference.md +++ b/API-Reference.md @@ -87,11 +87,79 @@ array.printTo(Serial); will write -``` +```json ["hello",3.1416] ``` +### JsonArray::createNestedArray() + +##### Description + +Adds a new nested array to the end of the array. + +##### Signature + +```c++ +JsonArray& createNestedArray(); +``` + +##### Return value + +A reference to the new `JsonArray`. +You can check `JsonArray::success()` to verify that the allocation succeeded. + +##### Example + +```c++ +StaticJsonBuffer<200> jsonBuffer; +JsonArray& array = jsonBuffer.createArray(); +array.add("hello"); +JsonArray& nested = array.createNestedArray(); +nested.add("world"); +array.printTo(Serial); +``` + +will write + +```json +["hello",["world"]] +``` + + +### JsonArray::createNestedObject() + +##### Description + +Adds a new nested object to the end of the array. + +##### Signature + +```c++ +JsonObject& createNestedObject(); +``` + +##### Return value + +A reference to the new `JsonObject`. +You can check `JsonObject::success()` to verify that the allocation succeeded. + +##### Example + +```c++ +StaticJsonBuffer<200> jsonBuffer; +JsonArray& array = jsonBuffer.createArray(); +JsonObject& nested = array.createNestedObject(); +nested["hello"] = "world"; +array.printTo(Serial); +``` + +will write + +```json +[{"hello":"world"}] +``` + ### JsonArray::get() @@ -693,7 +761,8 @@ To avoid this behavior, use a `const char*` key instead. ##### Return value -A reference to the new `JsonArray` +A reference to the new `JsonArray`. +You can check `JsonArray::success()` to verify that the allocatio succeeded. ##### Example @@ -744,7 +813,8 @@ To avoid this behavior, use a `const char*` key instead. ##### Return value -A reference to the new `JsonObject` +A reference to the new `JsonObject`. +You can check `JsonObject::success()` to verify that the allocatio succeeded. ##### Example