mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added IndentedPrint example
This commit is contained in:
		
							
								
								
									
										43
									
								
								examples/IndentedPrintExample/IndentedPrintExample.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								examples/IndentedPrintExample/IndentedPrintExample.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| /* | ||||
|  * Arduino JSON library - IndentedPrint example | ||||
|  * Benoit Blanchon 2014 - MIT License | ||||
|  */ | ||||
|  | ||||
| #include <JsonGenerator.h> | ||||
|  | ||||
| using namespace ArduinoJson::Generator; | ||||
|  | ||||
| void setup() | ||||
| { | ||||
|     Serial.begin(9600); | ||||
|      | ||||
|     JsonObject<1> json; | ||||
|     json["key"] = "value"; | ||||
|      | ||||
|     IndentedPrint serial(Serial);     | ||||
|     serial.setTabSize(4); | ||||
|      | ||||
|     serial.println("This is at indentation 0"); | ||||
|     serial.indent(); | ||||
|     serial.println("This is at indentation 1"); | ||||
|     serial.println("This is also at indentation 1"); | ||||
|     serial.indent(); | ||||
|     serial.println("This is at indentation 2"); | ||||
|      | ||||
|     serial.println("You can print JSON here, as usual:"); | ||||
|     serial.println(json); | ||||
|     serial.println(); | ||||
|          | ||||
|     serial.println("But you can also prettyPrint JSON here:"); | ||||
|     json.prettyPrintTo(serial);   | ||||
|     serial.println(); | ||||
|      | ||||
|     serial.unindent(); | ||||
|     serial.unindent(); | ||||
|     serial.println("This is back at indentation 0"); | ||||
| } | ||||
|  | ||||
| void loop() | ||||
| { | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user