Skip to main content

estimate_json_bytes

Function estimate_json_bytes 

Source
pub fn estimate_json_bytes(v: &Value) -> u64
Expand description

Approximate serialized JSON size of v, in bytes, without allocating.

Strings count their UTF-8 length plus quotes (escapes are ignored), numbers their decimal rendering, containers their brackets, commas and key quotes/colons. Close enough for accounting and budgets.