mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 19:42:12 +02:00
Added JsonPrintable.prettyPrintTo(Print&)
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
// This file is here to help the Arduino IDE find the .cpp files
|
// This file is here to help the Arduino IDE find the .cpp files
|
||||||
|
|
||||||
#include "JsonGenerator/EscapedString.cpp"
|
#include "JsonGenerator/EscapedString.cpp"
|
||||||
|
#include "JsonGenerator/IndentedPrintDecorator.cpp"
|
||||||
#include "JsonGenerator/JsonArrayBase.cpp"
|
#include "JsonGenerator/JsonArrayBase.cpp"
|
||||||
#include "JsonGenerator/JsonObjectBase.cpp"
|
#include "JsonGenerator/JsonObjectBase.cpp"
|
||||||
#include "JsonGenerator/JsonValue.cpp"
|
#include "JsonGenerator/JsonValue.cpp"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "JsonValue.h"
|
#include "JsonValue.h"
|
||||||
#include "Print.h"
|
#include "Print.h"
|
||||||
#include "Printable.h"
|
#include "Printable.h"
|
||||||
|
#include "IndentedPrintDecorator.h"
|
||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
@ -25,6 +26,12 @@ namespace ArduinoJson
|
|||||||
return printTo(sb);
|
return printTo(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t prettyPrintTo(Print& p) const
|
||||||
|
{
|
||||||
|
IndentedPrintDecorator decorator(p);
|
||||||
|
return printTo(decorator);
|
||||||
|
}
|
||||||
|
|
||||||
virtual size_t printTo(Print& p) const = 0;
|
virtual size_t printTo(Print& p) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ void setup()
|
|||||||
root["data"] = array;
|
root["data"] = array;
|
||||||
|
|
||||||
Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
root.prettyPrintTo(Serial); // same string indented
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
Reference in New Issue
Block a user