From 2997a405a085af9a0d3d7a62d5a5e6bb355ff71c Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 26 Aug 2014 12:48:59 +0200 Subject: [PATCH] Added IndentedPrint example --- .../IndentedPrintExample.ino | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 examples/IndentedPrintExample/IndentedPrintExample.ino diff --git a/examples/IndentedPrintExample/IndentedPrintExample.ino b/examples/IndentedPrintExample/IndentedPrintExample.ino new file mode 100644 index 00000000..15a5daa2 --- /dev/null +++ b/examples/IndentedPrintExample/IndentedPrintExample.ino @@ -0,0 +1,43 @@ +/* + * Arduino JSON library - IndentedPrint example + * Benoit Blanchon 2014 - MIT License + */ + +#include + +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() +{ + +} \ No newline at end of file