diff --git a/API-Reference.md b/API-Reference.md index e42e328..a9d6e37 100644 --- a/API-Reference.md +++ b/API-Reference.md @@ -245,8 +245,7 @@ array.printTo(Serial); Returns the size (in bytes) of an array with n elements. Can be very handy to determine the size of a StaticJsonBuffer. ##### Signatures -```c++ -``` + ##### Arguments ##### Return value ##### Example @@ -272,30 +271,81 @@ virtual ~JsonBuffer() {} Allocates an empty JsonArray. Returns a reference to the new JsonArray or JsonArray::invalid() if the allocation fails. + +**Fixed size.** +```c++ +StaticJsonBuffer<200> jsonBuffer; +``` + +**Returns the size (in bytes) of an object with n elements.** +**Can be very handy to determine the size of a StaticJsonBuffer.** + +```c++ +struct SensorData { + const char* name; + int time; + float value; +}; + +#define SENSORDATA_JSON_SIZE (**JSON_OBJECT_SIZE(3)**) + +``` + #### JsonBuffer::createArray() ##### Description +Allocates an empty JsonArray. + ##### Signatures ##### Arguments ##### Return value +Returns a reference to the new JsonArray or JsonArray::invalid() if the allocation fails. ##### Example - +```c++ +``` #### JsonBuffer::createObject() ##### Description +Allocates an empty JsonObject. + ##### Signatures +```c++ +``` ##### Arguments ##### Return value +Returns a reference to the new JsonObject or JsonObject::invalid() if the allocation fails. ##### Example #### JsonBuffer::parseArray() ##### Description +Allocates and populate a JsonArray from a JSON string. + // + // + // + // + // ##### Signatures +```c++ +``` ##### Arguments +The First argument is a pointer to the JSON string, the memory must be writable because the parser will insert null-terminators and replace escaped chars. +The second argument set the nesting limit (see comment on ) + +Default value of nesting limit of parseArray() and parseObject(). +DEFAULT_LIMIT: + The nesting limit is a contain on the level of nesting allowed in the JSON string. + If set to 0, only a flat array or objects can be parsed. + If set to 1, the object can contain nested arrays or objects but only 1 level deep. + And bigger values will allow more level of nesting. + The purpose of this feature is to prevent stack overflow that could lead to a security risk. + ##### Return value +Returns a reference to the new JsonObject or JsonObject::invalid() if the allocation fails. ##### Example #### JsonBuffer::parseObject() ##### Description ##### Signatures +```c++ +``` ##### Arguments ##### Return value ##### Example @@ -303,6 +353,8 @@ Returns a reference to the new JsonArray or JsonArray::invalid() if the allocati #### JsonBuffer::strdup() ##### Description ##### Signatures +```c++ +``` ##### Arguments ##### Return value ##### Example