diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f7482378..8defa258 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,11 +1,14 @@ diff --git a/README.md b/README.md index 1ccb8051..b0c7ae81 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ double longitude = root["data"][1]; [See JsonParserExample.ino](examples/JsonParserExample/JsonParserExample.ino) +Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size. + #### Encoding / Generating ```c++ @@ -78,6 +80,8 @@ root.printTo(Serial); [See JsonGeneratorExample.ino](examples/JsonGeneratorExample/JsonGeneratorExample.ino) +Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size. + Documentation ------------- diff --git a/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/examples/JsonGeneratorExample/JsonGeneratorExample.ino index 25bafac3..58306c8c 100644 --- a/examples/JsonGeneratorExample/JsonGeneratorExample.ino +++ b/examples/JsonGeneratorExample/JsonGeneratorExample.ino @@ -17,13 +17,13 @@ void setup() { // // 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. + // See https://bblanchon.github.io/ArduinoJson/assistant/ StaticJsonBuffer<200> jsonBuffer; // StaticJsonBuffer allocates memory on the stack, it can be // 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. // diff --git a/examples/JsonHttpClient/JsonHttpClient.ino b/examples/JsonHttpClient/JsonHttpClient.ino index 48f70c61..5edb817f 100644 --- a/examples/JsonHttpClient/JsonHttpClient.ino +++ b/examples/JsonHttpClient/JsonHttpClient.ino @@ -135,7 +135,7 @@ bool skipResponseHeaders() { // } bool readReponseContent(struct UserData* userData) { // 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 = JSON_OBJECT_SIZE(8) // the root object has 8 elements + JSON_OBJECT_SIZE(5) // the "address" object has 5 elements diff --git a/examples/JsonParserExample/JsonParserExample.ino b/examples/JsonParserExample/JsonParserExample.ino index 7e0e714b..d47f589f 100644 --- a/examples/JsonParserExample/JsonParserExample.ino +++ b/examples/JsonParserExample/JsonParserExample.ino @@ -17,13 +17,13 @@ void setup() { // // 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. + // See https://bblanchon.github.io/ArduinoJson/assistant/ StaticJsonBuffer<200> jsonBuffer; // StaticJsonBuffer allocates memory on the stack, it can be // replaced by DynamicJsonBuffer which allocates in the heap. - // It's simpler but less efficient. // - // DynamicJsonBuffer jsonBuffer; + // DynamicJsonBuffer jsonBuffer(200); // JSON input string. // diff --git a/examples/JsonServer/JsonServer.ino b/examples/JsonServer/JsonServer.ino index d3fec3ec..555842b8 100644 --- a/examples/JsonServer/JsonServer.ino +++ b/examples/JsonServer/JsonServer.ino @@ -2,9 +2,9 @@ // Created by Benoit Blanchon. // Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe -#include -#include #include +#include +#include byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; IPAddress ip(192, 168, 0, 177); @@ -64,6 +64,8 @@ void loop() { if (client) { bool success = readRequest(client); if (success) { + // Use https://bblanchon.github.io/ArduinoJson/assistant/ to + // compute the right size for the buffer StaticJsonBuffer<500> jsonBuffer; JsonObject& json = prepareResponse(jsonBuffer); writeResponse(client, json); diff --git a/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/examples/JsonUdpBeacon/JsonUdpBeacon.ino index 2975fad4..b3bd5fc5 100644 --- a/examples/JsonUdpBeacon/JsonUdpBeacon.ino +++ b/examples/JsonUdpBeacon/JsonUdpBeacon.ino @@ -49,6 +49,8 @@ void setup() { void loop() { delay(1000); + // Use https://bblanchon.github.io/ArduinoJson/assistant/ to + // compute the right size for the buffer StaticJsonBuffer<300> jsonBuffer; JsonObject& json = buildJson(jsonBuffer); sendJson(json);