forked from bblanchon/ArduinoJson
Merge branch '4.0'
Conflicts: JsonGenerator.cpp JsonGenerator.h JsonGenerator/EscapedString.cpp JsonGenerator/EscapedString.h JsonGenerator/IndentedPrint.cpp JsonGenerator/IndentedPrint.h JsonGenerator/JsonArray.h JsonGenerator/JsonArrayBase.cpp JsonGenerator/JsonArrayBase.h JsonGenerator/JsonObject.h JsonGenerator/JsonObjectBase.cpp JsonGenerator/JsonObjectBase.h JsonGenerator/JsonPrettyPrint.cpp JsonGenerator/JsonPrettyPrint.h JsonGenerator/JsonPrintable.cpp JsonGenerator/JsonPrintable.h JsonGenerator/JsonValue.cpp JsonGenerator/JsonValue.h JsonGenerator/Print.cpp JsonGenerator/Print.h JsonGenerator/Printable.h JsonGenerator/StringBuilder.cpp JsonGenerator/StringBuilder.h JsonGeneratorTests/EscapedStringTests.cpp JsonGeneratorTests/Issue10.cpp JsonGeneratorTests/JsonArrayTests.cpp JsonGeneratorTests/JsonObject_Indexer_Tests.cpp JsonGeneratorTests/JsonObject_PrintTo_Tests.cpp JsonGeneratorTests/JsonValue_Cast_Tests.cpp JsonGeneratorTests/JsonValue_PrintTo_Tests.cpp JsonGeneratorTests/PrettyPrint_Array_Tests.cpp JsonGeneratorTests/PrettyPrint_Object_Tests.cpp JsonGeneratorTests/PrettyPrint_String_Tests.cpp JsonGeneratorTests/StringBuilderTests.cpp JsonParser.cpp JsonParser.h JsonParser/JsonArray.cpp JsonParser/JsonArray.h JsonParser/JsonArrayIterator.h JsonParser/JsonObject.cpp JsonParser/JsonObject.h JsonParser/JsonObjectIterator.h JsonParser/JsonPair.h JsonParser/JsonParser.h JsonParser/JsonParserBase.cpp JsonParser/JsonParserBase.h JsonParser/JsonToken.cpp JsonParser/JsonToken.h JsonParser/JsonValue.cpp JsonParser/JsonValue.h JsonParser/README.md JsonParserTests/GbathreeBug.cpp JsonParserTests/JsonArrayIteratorTests.cpp JsonParserTests/JsonArrayTests.cpp JsonParserTests/JsonObjectIteratorTests.cpp JsonParserTests/JsonObjectTests.cpp JsonParserTests/JsonStringTests.cpp JsonParserTests/TestHashGenerator.cpp README.md library.json
This commit is contained in:
57
README.md
57
README.md
@ -1,6 +1,8 @@
|
||||
Arduino JSON library
|
||||
====================
|
||||
|
||||
[](https://travis-ci.org/bblanchon/ArduinoJson)
|
||||
|
||||
*An elegant and efficient JSON library for embedded systems.*
|
||||
|
||||
It's design to have the most intuitive API, the smallest footprint and works without any allocation on the heap (no malloc).
|
||||
@ -10,31 +12,48 @@ It has been written with Arduino in mind, but it isn't linked to Arduino librari
|
||||
Features
|
||||
--------
|
||||
|
||||
* JSON decoding: [see documentation here](/JsonParser/)
|
||||
* JSON encoding: [see documentation here](/JsonGenerator/)
|
||||
* JSON decoding
|
||||
* JSON encoding (with optional indentation)
|
||||
* Elegant API, very easy to use
|
||||
* Fixed memory allocation (no malloc)
|
||||
* Small footprint
|
||||
* MIT License
|
||||
|
||||
Feature comparison
|
||||
------------------
|
||||
Quick start
|
||||
-----------
|
||||
|
||||
| Library | Memory allocation | Nested objects | Parser size | Encoder size |
|
||||
| ------------ | ----------------- | -------------- | ----------- | ------------- |
|
||||
| Arduino JSON | static | yes | 2760 Bytes | 862 bytes |
|
||||
| json-arduino | dynamic | no | 3348 (+21%) | not supported |
|
||||
| aJson | dynamic | yes | 5088 (+84%) | 4678 (+540%) |
|
||||
#### Decoding / Parsing
|
||||
|
||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
|
||||
"Parser size" was measured with a program parsing `{"sensor":"outdoor","value":25.6}`.
|
||||
For each library, I wrote a program that extracts a string and a float. I subtracted the size of a program doing the same without any JSON parsing involved. [Source files are here](https://gist.github.com/bblanchon/e8ba914a7109f3642c0f).
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
"Encoder size" was measured with a program generating `{"sensor":"outdoor","value":25.6}`.
|
||||
[Source files are here](https://gist.github.com/bblanchon/60224e9dcfeab4ddc7e9).
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
|
||||
In each case the target platform was an Arduino Duemilanove and Arduino IDE 1.0.5 was used.
|
||||
const char* sensor = root["sensor"];
|
||||
long time = root["time"];
|
||||
double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
|
||||
Links: [json-arduino](https://github.com/not404/json-arduino), [aJson](https://github.com/interactive-matter/aJson)
|
||||
[See complete guide](/doc/Decoding JSON.md)
|
||||
|
||||
#### Encoding / Generating
|
||||
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
|
||||
JsonArray& data = root.createNestedArray("data");
|
||||
data.add(48.756080, 6); // 6 is the number of decimals to print
|
||||
data.add(2.302038, 6); // if not specified, 2 digits are printed
|
||||
|
||||
root.printTo(Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
|
||||
[See complete guide](/doc/Encoding JSON.md)
|
||||
|
||||
Testimonials
|
||||
------------
|
||||
@ -55,10 +74,6 @@ From GitHub user `zacsketches`:
|
||||
> I've been watching you consistently develop this library over the past six months, and I used it today for a publish and subscribe architecture designed to help hobbyists move into more advanced robotics. Your library allowed me to implement remote subscription in order to facilitate multi-processor robots.
|
||||
> ArduinoJson saved me a week's worth of time!!
|
||||
|
||||
Related blog posts
|
||||
-----
|
||||
---
|
||||
|
||||
* [The project I originally wrote this library for](http://blog.benoitblanchon.fr/rfid-payment-terminal/)
|
||||
* [Motivation for this library](http://blog.benoitblanchon.fr/arduino-json-parser/)
|
||||
* [Release of version 2](http://blog.benoitblanchon.fr/arduino-json-v2-0/)
|
||||
* [Release of version 3](http://blog.benoitblanchon.fr/arduino-json-v3-0/)
|
||||
Found this library useful? [Help me back with a donation!](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donate%40benoitblanchon%2efr&lc=GB&item_name=Benoit%20Blanchon&item_number=Arduino%20JSON¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) :smile:
|
Reference in New Issue
Block a user