Skip to main content

encode_value

Function encode_value 

Source
pub fn encode_value(buf: &mut Vec<u8>, v: &Value) -> Result<(), String>
Expand description

Encode a JSON value canonically.

Numbers are the interesting case. A JSON number is committed by its REPRESENTATION as parsed — i64, u64 or f64 — rather than by its mathematical value, so 1 and 1.0 commit differently. That is the honest choice for a database that round-trips them differently, and the alternative (normalising every integral float to an integer) would make a root that cannot distinguish two documents the engine can.