Skip to content

Commit

Permalink
Added prettyPrintTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Sep 1, 2014
1 parent ec84365 commit cd88fb0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion JsonGenerator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Features
* Fixed memory allocation (no malloc)
* Small footprint
* Supports nested objects
* Supports indented output
* Implements Arduino's `Printable interface
* MIT License

Expand Down Expand Up @@ -177,6 +178,13 @@ Whether you have a `JsonArray` or a `JsonObject`, simply call `printTo()` with t
char buffer[256];
array.printTo(buffer, sizeof(buffer));

> ##### Want an indented output?
> By default the generated JSON is as small as possible. It contains no extra space, nor line break.
> But if you want an indented, more readable output, you can.
> Simply call `prettyPrintTo` instead of `printTo()`:
>
> array.prettyPrintTo(buffer, sizeof(buffer));
#### Send to a stream

It's very likely that the generated JSON will end up in a stream like `Serial` or `EthernetClient `, so you can save some time and memory by doing this:
Expand All @@ -190,7 +198,7 @@ or
> ##### About the Printable interface
> `JsonArray` and `JsonObject` implement Arduino's `Printable` interface.
> This is why you can call `Serial.print()` like in the example above.
> You can do the same with any other implementation of `Print`: `HardwareSerial`, `SoftwareSerial`, `LiquidCrystal`, `EthernetClient`, `WiFiClient`...
> You can do the same with any other implementation of `Print`: `HardwareSerial`, `SoftwareSerial`, `LiquidCrystal`, `EthernetClient`, `WiFiClient`, `Wire`...

Memory usage
Expand Down

0 comments on commit cd88fb0

Please sign in to comment.