JsonArray::printTo()
⚠️ CAUTION: SLIPPERY FLOOR ⚠️
The Arduino Library Manager installs the ArduinoJson version 6 by default.However, using version 5 is highly recommended because version 6 is still in beta stage.
Open the Arduino Library Manager and make sure that ArduinoJson version 5.13.4 is installed.
Description
Serializes the JsonArray
to create a minified JSON document.
If you want a pretty JSON with spaces and line breaks, use JsonArray::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
orstd::string
.
Return value
The number of bytes written.
Example
StaticJsonBuffer<200> jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
array.add("hello");
array.add("world");
array.printTo(Serial);
will write the following string to the serial port:
["hello","world"]