File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ namespace ArduinoJson
11
11
{
12
12
namespace Generator
13
13
{
14
+ // Decorator on top of Print to allow indented output.
15
+ // This class is used by JsonPrintable::prettyPrintTo() but can also be used
16
+ // for your own purpose, like logging.
14
17
class IndentedPrint : public Print
15
18
{
16
19
public:
@@ -25,8 +28,13 @@ namespace ArduinoJson
25
28
26
29
virtual size_t write (uint8_t );
27
30
31
+ // Adds one level of indentation
28
32
void indent ();
33
+
34
+ // Removes one level of indentation
29
35
void unindent ();
36
+
37
+ // Set the number of space printed for each level of indentation
30
38
void setTabSize (uint8_t n);
31
39
32
40
private:
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ namespace ArduinoJson
12
12
{
13
13
namespace Generator
14
14
{
15
+ // Converts a compact JSON string into an indented one.
15
16
class JsonPrettyPrint : public Print
16
17
{
17
18
public:
Original file line number Diff line number Diff line change @@ -13,16 +13,27 @@ namespace ArduinoJson
13
13
{
14
14
namespace Generator
15
15
{
16
+ // Contains methods to generate a JSON string.
17
+ // Implemented by both JsonObject and JsonArray
16
18
class JsonPrintable : public Printable
17
19
{
18
20
public:
19
21
22
+ // Generates the compact JSON string and sends it to a Print stream
20
23
virtual size_t printTo (Print& p) const = 0;
21
24
25
+ // Generates the compact JSON string and writes it in a buffer
22
26
size_t printTo (char * buffer, size_t bufferSize) const ;
23
27
24
- size_t prettyPrintTo (IndentedPrint& p) const ;
28
+ // Generates the indented JSON string and sends it to a Print stream
25
29
size_t prettyPrintTo (Print& p) const ;
30
+
31
+ // Generates the indented JSON string and sends it to a IndentedPrint stream
32
+ // This overload allows a finer control of the output because you can customize
33
+ // the IndentedPrint.
34
+ size_t prettyPrintTo (IndentedPrint& p) const ;
35
+
36
+ // Generates the indented JSON string and writes it in a buffer
26
37
size_t prettyPrintTo (char * buffer, size_t bufferSize) const ;
27
38
};
28
39
}
You can’t perform that action at this time.
0 commit comments