Description

Computes the length of the minified JSON document that serializeJson() produces, excluding the null-terminator.

This function is handy to fill the Content-Length header in an HTTP message.

Signatures

size_t measureJson(TSource src);

Arguments

Return value

The number of characters that serializeJson() produces, excluding the null-terminator.

Example

// Send headers
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(measureJson(doc));

// Terminate headers
client.println();

// Send body
serializeJson(doc, client);

See also

Global warming stripes by Professor Ed Hawkins (University of Reading)