mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Don't use JsonBuffer to create or parse objects and arrays.
* Added DynamicJsonArray and StaticJsonArray * Added DynamicJsonObject and StaticJsonObject * Added DynamicJsonVariant and StaticJsonVariant * Added deserializeJson() * Removed JsonBuffer::parseArray(), parseObject() and parse() * Removed JsonBuffer::createArray() and createObject()
This commit is contained in:
		| @@ -32,12 +32,12 @@ void loadConfiguration(const char *filename, Config &config) { | ||||
|   // Allocate the memory pool on the stack. | ||||
|   // Don't forget to change the capacity to match your JSON document. | ||||
|   // Use arduinojson.org/assistant to compute the capacity. | ||||
|   StaticJsonBuffer<512> jsonBuffer; | ||||
|   StaticJsonObject<512> root; | ||||
|  | ||||
|   // Parse the root object | ||||
|   JsonObject &root = jsonBuffer.parseObject(file); | ||||
|   bool success = deserializeJson(root, file); | ||||
|  | ||||
|   if (!root.success()) | ||||
|   if (!success) | ||||
|     Serial.println(F("Failed to read file, using default configuration")); | ||||
|  | ||||
|   // Copy values from the JsonObject to the Config | ||||
| @@ -65,10 +65,7 @@ void saveConfiguration(const char *filename, const Config &config) { | ||||
|   // Allocate the memory pool on the stack | ||||
|   // Don't forget to change the capacity to match your JSON document. | ||||
|   // Use https://arduinojson.org/assistant/ to compute the capacity. | ||||
|   StaticJsonBuffer<256> jsonBuffer; | ||||
|  | ||||
|   // Parse the root object | ||||
|   JsonObject &root = jsonBuffer.createObject(); | ||||
|   StaticJsonObject<256> root; | ||||
|  | ||||
|   // Set the values | ||||
|   root["hostname"] = config.hostname; | ||||
| @@ -141,4 +138,4 @@ void loop() { | ||||
| // The book "Mastering ArduinoJson" contains a case study of a project that has | ||||
| // a complex configuration with nested members. | ||||
| // Contrary to this example, the project in the book uses the SPIFFS filesystem. | ||||
| // Please check it out at: https://arduinojson.org/book/ | ||||
| // Please check it out at: https://arduinojson.org/book/ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user