mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 00:32:37 +01:00 
			
		
		
		
	Added links to the ArduinoJson assistant (issue #513)
This commit is contained in:
		| @@ -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. | ||||
|   // | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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. | ||||
|   // | ||||
|   | ||||
| @@ -2,9 +2,9 @@ | ||||
| // Created by Benoit Blanchon. | ||||
| // Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe | ||||
|  | ||||
| #include <SPI.h> | ||||
| #include <Ethernet.h> | ||||
| #include <ArduinoJson.h> | ||||
| #include <Ethernet.h> | ||||
| #include <SPI.h> | ||||
|  | ||||
| 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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user