From 935cb068ab84ddc9d528ec983656b0eda6ca5410 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 5 Jul 2014 16:09:37 +0200 Subject: [PATCH] Updated README.md --- JsonParser/README.md | 48 +++++++++++++++++--------------------------- README.md | 17 ++++++++++++---- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/JsonParser/README.md b/JsonParser/README.md index ce330a71..7b66338f 100644 --- a/JsonParser/README.md +++ b/JsonParser/README.md @@ -1,11 +1,11 @@ -An efficient JSON parser for Arduino -==================================== +Arduino JSON library - Parser +============================= This library is an thin C++ wrapper around the *jsmn* tokenizer: http://zserge.com/jsmn.html It's design to be very lightweight, works without any allocation on the heap (no malloc) and supports nested objects. -It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library on 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. Features @@ -13,33 +13,26 @@ Features * Based on the well-proven [jsmn](http://zserge.com/jsmn.html) tokenizer * Supports nested objects -* Works with fixed memory allocation : no `malloc()` -* Low footprint +* Elegant API, very easy to use +* Fixed memory allocation (no malloc) +* Small footprint * MIT License Example ------- - char json[] = "{\"Name\":\"Blanchon\",\"Skills\":[\"C\",\"C++\",\"C#\"],\"Age\":32,\"Online\":true}"; + char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; JsonParser<32> parser; - JsonHashTable hashTable = parser.parseHashTable(json); + JsonHashTable root = parser.parseHashTable(json); - if (!hashTable.success()) - { - return; - } - - char* name = hashTable.getString("Name"); - - JsonArray skills = hashTable.getArray("Skills"); - - int age = hashTable.getLong("Age"); - - bool online = hashTable.getBool("Online"); + char* sensor = root.getString("sensor"); + long time = root.getLong("time"); + + JsonArray coords = root.getArray("data"); How to use ? @@ -49,13 +42,15 @@ How to use ? Download the library and extract it to: - /libraries/ArduinoJsonParser + /libraries/ArduinoJson ### 2. Import in your sketch -Just add the following line on the top of your `.ino` file: +Just add the following lines at the top of your `.ino` file: #include + + using namespace ArduinoJson::Parser; ### 3. Create a parser @@ -233,7 +228,7 @@ Code size Theses tables has been created by analyzing the map file generated by AVR-GCC after adding `-Wl,-Map,foo.map` to the command line. -As you'll see the code size if between 1680 and 3528 bytes, depending on the features you use. +As you'll see the code size is between 1680 and 3528 bytes, depending on the features you use. ### Minimum setup @@ -406,11 +401,4 @@ As you'll see the code size if between 1680 and 3528 bytes, depending on the fea TOTAL 710 - - - -Links ------ - -* [The project for which I made me this library](http://blog.benoitblanchon.fr/rfid-payment-terminal/) -* [Blog post on the motivation for this library](http://blog.benoitblanchon.fr/arduino-json-parser/) \ No newline at end of file + \ No newline at end of file diff --git a/README.md b/README.md index d4937882..71f02be5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ It's design to be very lightweight, works without any allocation on the heap (no 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. -# Features +Features +-------- * JSON decoding: [more details here](/JsonParser/) * JSON encoding: [more details here](/JsonGenerator/) @@ -16,7 +17,8 @@ It has been written with Arduino in mind, but it isn't linked to Arduino librari * Small footprint * MIT License -# Feature comparison +Feature comparison +------------------ | Library | Memory allocation | Nested objects | Encoding | Parser size | Encoder size | | ------------ | ----------------- | -------------- | -------- | ----------- | ------------ | @@ -34,7 +36,8 @@ In each case the target platform was an Arduino Duemilanove and Arduino IDE 1.0. Links: [json-arduino](https://github.com/not404/json-arduino), [aJson](https://github.com/interactive-matter/aJson) -# Testimonials +Testimonials +------------ From Arduino's Forum user `jflaplante`: > I tried the [aJson and json-arduino] before trying your library. I always ran into memory problem after a while. @@ -44,4 +47,10 @@ From Arduino's Forum user `gbathree`: > Thanks so much - this is an awesome library! If you want to see what we're doing with it - the project is located at www.photosynq.org. From StackOverflow user `thegreendroid`: -> It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality. \ No newline at end of file +> It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality. + +Links +----- + +* [The project for which I made me this library](http://blog.benoitblanchon.fr/rfid-payment-terminal/) +* [Blog post on the motivation for this library](http://blog.benoitblanchon.fr/arduino-json-parser/) \ No newline at end of file