Added links to the ArduinoJson assistant (issue #513)

This commit is contained in:
Benoit Blanchon committed 2017-05-27 15:32:12 +02:00
1 parent 7415f206ea
commit 574c00c096
7 files changed
+24 -13

No files matched your search

+9 -6
View File
@@ -1,11 +1,14 @@
<!-- <!--
Thanks for using ArduinoJson :-) Before opening an issue, please read the FAQ:
Before opening an issue, please make sure you've read these:
https://bblanchon.github.io/ArduinoJson/faq/ https://bblanchon.github.io/ArduinoJson/faq/
https://bblanchon.github.io/ArduinoJson/doc/pitfalls/
Next, make sure you provide all the relevant information: platform, code snippet, and error messages. Please provide all the relevant information:
* good title
* short description of the problem
* target platform
* compiler model and version
* MVCE (https://stackoverflow.com/help/mcve)
* compiler output
Please be concise! Good questions get fast answers!
--> -->
+4
View File
@@ -58,6 +58,8 @@ double longitude = root["data"][1];
[See JsonParserExample.ino](examples/JsonParserExample/JsonParserExample.ino) [See JsonParserExample.ino](examples/JsonParserExample/JsonParserExample.ino)
Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size.
#### Encoding / Generating #### Encoding / Generating
```c++ ```c++
@@ -78,6 +80,8 @@ root.printTo(Serial);
[See JsonGeneratorExample.ino](examples/JsonGeneratorExample/JsonGeneratorExample.ino) [See JsonGeneratorExample.ino](examples/JsonGeneratorExample/JsonGeneratorExample.ino)
Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size.
Documentation Documentation
------------- -------------
@@ -17,13 +17,13 @@ void setup() {
// //
// Inside the brackets, 200 is the size of the pool in bytes. // Inside the brackets, 200 is the size of the pool in bytes.
// If the JSON object is more complex, you need to increase that value. // If the JSON object is more complex, you need to increase that value.
// See https://bblanchon.github.io/ArduinoJson/assistant/
StaticJsonBuffer<200> jsonBuffer; StaticJsonBuffer<200> jsonBuffer;
// StaticJsonBuffer allocates memory on the stack, it can be // StaticJsonBuffer allocates memory on the stack, it can be
// replaced by DynamicJsonBuffer which allocates in the heap. // replaced by DynamicJsonBuffer which allocates in the heap.
// It's simpler but less efficient.
// //
// DynamicJsonBuffer jsonBuffer; // DynamicJsonBuffer jsonBuffer(200);
// Create the root of the object tree. // Create the root of the object tree.
// //
+1 -1
View File
@@ -135,7 +135,7 @@ bool skipResponseHeaders() {
// } // }
bool readReponseContent(struct UserData* userData) { bool readReponseContent(struct UserData* userData) {
// Compute optimal size of the JSON buffer according to what we need to parse. // Compute optimal size of the JSON buffer according to what we need to parse.
// This is only required if you use StaticJsonBuffer. // See https://bblanchon.github.io/ArduinoJson/assistant/
const size_t BUFFER_SIZE = const size_t BUFFER_SIZE =
JSON_OBJECT_SIZE(8) // the root object has 8 elements JSON_OBJECT_SIZE(8) // the root object has 8 elements
+ JSON_OBJECT_SIZE(5) // the "address" object has 5 elements + JSON_OBJECT_SIZE(5) // the "address" object has 5 elements
@@ -17,13 +17,13 @@ void setup() {
// //
// Inside the brackets, 200 is the size of the pool in bytes, // Inside the brackets, 200 is the size of the pool in bytes,
// If the JSON object is more complex, you need to increase that value. // If the JSON object is more complex, you need to increase that value.
// See https://bblanchon.github.io/ArduinoJson/assistant/
StaticJsonBuffer<200> jsonBuffer; StaticJsonBuffer<200> jsonBuffer;
// StaticJsonBuffer allocates memory on the stack, it can be // StaticJsonBuffer allocates memory on the stack, it can be
// replaced by DynamicJsonBuffer which allocates in the heap. // replaced by DynamicJsonBuffer which allocates in the heap.
// It's simpler but less efficient.
// //
// DynamicJsonBuffer jsonBuffer; // DynamicJsonBuffer jsonBuffer(200);
// JSON input string. // JSON input string.
// //
+4 -2
View File
@@ -2,9 +2,9 @@
// Created by Benoit Blanchon. // Created by Benoit Blanchon.
// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe // Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe
#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 0, 177); IPAddress ip(192, 168, 0, 177);
@@ -64,6 +64,8 @@ void loop() {
if (client) { if (client) {
bool success = readRequest(client); bool success = readRequest(client);
if (success) { if (success) {
// Use https://bblanchon.github.io/ArduinoJson/assistant/ to
// compute the right size for the buffer
StaticJsonBuffer<500> jsonBuffer; StaticJsonBuffer<500> jsonBuffer;
JsonObject& json = prepareResponse(jsonBuffer); JsonObject& json = prepareResponse(jsonBuffer);
writeResponse(client, json); writeResponse(client, json);
+2
View File
@@ -49,6 +49,8 @@ void setup() {
void loop() { void loop() {
delay(1000); delay(1000);
// Use https://bblanchon.github.io/ArduinoJson/assistant/ to
// compute the right size for the buffer
StaticJsonBuffer<300> jsonBuffer; StaticJsonBuffer<300> jsonBuffer;
JsonObject& json = buildJson(jsonBuffer); JsonObject& json = buildJson(jsonBuffer);
sendJson(json); sendJson(json);