measureJsonPretty()
Description
Computes the length of the prettified JSON document that serializeJsonPretty() produces, excluding the null-terminator.
This function is handy to fill the Content-Length header of an HTTP message.
Signature
size_t measureJsonPretty(TSource src);
Arguments
src: the value to serialize. It can be aJsonDocument,JsonArray,JsonArrayConst,JsonObject,JsonObjectConst,JsonVariant, orJsonVariantConst.
Return value
The number of characters that serializeJsonPretty()produces, excluding the null-terminator.
Example
// Send headers
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(measureJsonPretty(doc));
// Terminate headers
client.println();
// Send body
serializeJsonPretty(doc, client);