Description

Serializes the JsonObject to create a prettified JSON document.

If you want a “minified” JSON document, use JsonObject::printTo()

Signatures

size_t prettyPrintTo(char* buffer, size_t size) const;
size_t prettyPrintTo(char buffer[size]) const;
size_t prettyPrintTo(Print &) const;
size_t prettyPrintTo(String &) const;
size_t prettyPrintTo(std::string &) const;

Arguments

The destination where the JSON document should be written. It can be either:

  • a buffer with specified size (the size includes the zero-terminator),
  • an implementation of Print (like Serial, EthernetClient…),
  • a String or an std::string.

Return value

The number of bytes written.

Example

StaticJsonBuffer<200> jsonBuffer;
JsonObject& object = jsonBuffer.createObject();
object["hello"] = "world";
object.prettyPrintTo(Serial);

will write the following string to the serial output:

{
  "hello": "world"
}

See also