mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Added operator == to compare JsonVariant and strings (issue #402)
				
					
				
			This commit is contained in:
		| @@ -39,9 +39,14 @@ void setup() { | ||||
|   // JsonBuffer. | ||||
|   root["sensor"] = F("gps"); | ||||
|  | ||||
|   // You can compare the content of a JsonVariant to a Flash String | ||||
|   if (root["sensor"] == F("gps")) { | ||||
|     // ... | ||||
|   } | ||||
|  | ||||
| #else | ||||
|  | ||||
| #warning PROGMEM is only supported on AVR architecture | ||||
| #warning PROGMEM is not supported on this platform | ||||
|  | ||||
| #endif | ||||
| } | ||||
|   | ||||
| @@ -48,6 +48,11 @@ void setup() { | ||||
|   // WARNING: the content of the String will be duplicated in the JsonBuffer. | ||||
|   root[String("sen") + "sor"] = String("gp") + "s"; | ||||
|  | ||||
|   // You can compare the content of a JsonObject with a String | ||||
|   if (root["sensor"] == sensor) { | ||||
|     // ... | ||||
|   } | ||||
|  | ||||
|   // Lastly, you can print the resulting JSON to a String | ||||
|   String output; | ||||
|   root.printTo(output); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user