forked from bblanchon/ArduinoJson
Updated README
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
Arduino JSON library - Generator
|
Arduino JSON library - Generator
|
||||||
================================
|
================================
|
||||||
|
|
||||||
This library is a simple JSON encoder for embedded systems.
|
*An elegant and efficient JSON encoder for embedded systems.*
|
||||||
|
|
||||||
It's design to be very lightweight, works without any allocation on the heap (no malloc) and supports nested objects.
|
It's design to have the most intuitive API, the smallest footprint and works without any allocation on the heap (no malloc).
|
||||||
|
|
||||||
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
||||||
|
|
||||||
@ -11,10 +11,10 @@ It has been written with Arduino in mind, but it isn't linked to Arduino librari
|
|||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* Supports nested objects
|
|
||||||
* Elegant API, very easy to use
|
* Elegant API, very easy to use
|
||||||
* Fixed memory allocation (no malloc)
|
* Fixed memory allocation (no malloc)
|
||||||
* Small footprint
|
* Small footprint
|
||||||
|
* Supports nested objects
|
||||||
* Implements Arduino's `Printable interface
|
* Implements Arduino's `Printable interface
|
||||||
* MIT License
|
* MIT License
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ Example
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
JsonArray<2> array;
|
JsonArray<2> array;
|
||||||
array.add<6>(48.756080);
|
array.add<6>(48.756080); // <6> specifies the number of digits in the output
|
||||||
array.add<6>(2.302038);
|
array.add<6>(2.302038); // (the default is 2)
|
||||||
|
|
||||||
JsonObject<3> root;
|
JsonObject<3> root;
|
||||||
root["sensor"] = "gps";
|
root["sensor"] = "gps";
|
||||||
@ -80,7 +80,7 @@ Then you can add strings, integer, booleans, etc:
|
|||||||
array.add(42);
|
array.add(42);
|
||||||
array.add(true);
|
array.add(true);
|
||||||
|
|
||||||
There are two syntaxes for the floating point values:
|
There are two syntaxes for floating point values:
|
||||||
|
|
||||||
array.add<4>(3.1415); // 4 digits: "3.1415"
|
array.add<4>(3.1415); // 4 digits: "3.1415"
|
||||||
array.add(3.14); // 2 digits: "3.14"
|
array.add(3.14); // 2 digits: "3.14"
|
||||||
@ -130,6 +130,11 @@ or
|
|||||||
JsonObject<8> nestedObject;
|
JsonObject<8> nestedObject;
|
||||||
object["key7"] = nestedObject;
|
object["key7"] = nestedObject;
|
||||||
|
|
||||||
|
> ##### Other JsonObject functions
|
||||||
|
> * `object.add(key, value)` is a synonym for `object[key] = value`
|
||||||
|
> * `object.containsKey(key)` returns `true` is the `key` is present in `object`
|
||||||
|
> * `object.remove(key)` removes the `value` associated with `key`
|
||||||
|
|
||||||
### 4. Get the JSON string
|
### 4. Get the JSON string
|
||||||
|
|
||||||
There are two ways tho get the resulting JSON string.
|
There are two ways tho get the resulting JSON string.
|
||||||
@ -177,15 +182,20 @@ This table is for an 8-bit Arduino, types would be bigger on a 32-bit processor.
|
|||||||
Code size
|
Code size
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
The following values has been obtained with Arduino IDE 1.0.5, targeting an Arduino Duelmilanove with an ATmega 328.
|
||||||
|
|
||||||
### Minimum setup
|
### Minimum setup
|
||||||
|
|
||||||
| Function | Size |
|
| Function | Size |
|
||||||
| ---------------------------- | ---- |
|
| ----------------------------------- | ---- |
|
||||||
| `JsonObjectBase::printTo()` | 222 |
|
| `JsonObjectBase::printTo()` | 234 |
|
||||||
| `EscapedString::printTo()` | 202 |
|
| `EscapedString::printTo()` | 196 |
|
||||||
| `JsonArrayBase::printTo()` | 164 |
|
| `JsonArrayBase::printTo()` | 164 |
|
||||||
| `Print::print(char const*)` | 146 |
|
| `Print::print(char const*)` | 146 |
|
||||||
| `JsonValue::printStringTo()` | 6 |
|
| `JsonObjectBase::operator[]` | 114 |
|
||||||
|
| `JsonObjectBase::getMatchingPair()` | 72 |
|
||||||
|
| `JsonValue::printPrintableTo()` | 40 |
|
||||||
|
| `JsonValue::printStringTo()` | 12 |
|
||||||
|
|
||||||
### Additional space for integers
|
### Additional space for integers
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ Arduino JSON library
|
|||||||
|
|
||||||
*An elegant and efficient JSON library for embedded systems.*
|
*An elegant and efficient JSON library for embedded systems.*
|
||||||
|
|
||||||
It's design to be very lightweight, works without any allocation on the heap (no malloc).
|
It's design to have the most intuitive API, the smallest footprint and works without any allocation on the heap (no malloc).
|
||||||
|
|
||||||
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user