API Reference
JsonObject::printTo()
Description
Serializes the JsonObject
to create a minified JSON document.
If you want a prettified JSON document, use JsonObject::prettyPrintTo()
.
Signatures
size_t printTo(char* buffer, size_t size) const;
size_t printTo(char buffer[size]) const;
size_t printTo(Print &) const;
size_t printTo(String &) const;
size_t printTo(std::string &) const;
Arguments
The destination where the JSON document should be written. It can be either:
- a
buffer
with specifiedsize
(the size includes the zero-terminator), - an implementation of
Print
(likeSerial
,EthernetClient
…), - a
String
or anstd::string
.
Return value
The number of bytes written.
Example
StaticJsonBuffer<200> jsonBuffer;
JsonObject& object = jsonBuffer.createObject();
object["hello"] = "world";
object.printTo(Serial);
will write the following string to the serial port:
{"hello":"world"}