mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Added StaticJsonDocument and DynamicJsonDocument.
Removed StaticJsonArray and DynamicJsonArray. Removed StaticJsonObject and DynamicJsonObject. Removed StaticJsonVariant and DynamicJsonVariant.
This commit is contained in:
		| @@ -70,19 +70,21 @@ void setup() { | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   // Allocate JsonBuffer | ||||
|   // Allocate the JSON document | ||||
|   // Use arduinojson.org/assistant to compute the capacity. | ||||
|   const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60; | ||||
|   DynamicJsonObject root(capacity); | ||||
|   DynamicJsonDocument doc(capacity); | ||||
|  | ||||
|   // Parse JSON object | ||||
|   JsonError error = deserializeJson(root, client); | ||||
|   JsonError error = deserializeJson(doc, client); | ||||
|   if (error) { | ||||
|     Serial.println(F("Parsing failed!")); | ||||
|     Serial.print(F("deserializeJson() failed: ")); | ||||
|     Serial.println(error.c_str()); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   // Extract values | ||||
|   JsonObject& root = doc.as<JsonObject>(); | ||||
|   Serial.println(F("Response:")); | ||||
|   Serial.println(root["sensor"].as<char*>()); | ||||
|   Serial.println(root["time"].as<char*>()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user