Description

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

This function is handy to fill the Content-Length header.

Signature

size_t measureLength() const

Return value

The number of characters that JsonVariant::printTo() produces, excluding the null-terminator.

Example

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

// Terminate headers
client.println();

// Send body
root.printTo(client);

See also