JsonObject::measurePrettyLength()
Description
Computes the length of the prettified JSON document that JsonObject::prettyPrintTo()
produces, excluding the null-terminator.
This function is handy to fill the Content-Length
header.
Signature
size_t measurePrettyLength() const
Return value
The number of characters that JsonObject::prettyPrintTo()
produces, excluding the null-terminator.
Example
// Send headers
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(root.measurePrettyLength());
// Terminate headers
client.println();
// Send body
root.prettyPrintTo(client);