Expand description
JSON output that matches pi’s JSON.stringify.
serde_json and JavaScript escape strings the same way but print numbers
differently: JavaScript writes 0.000003 and 5 where serde_json writes
3e-6 and 5.0. These functions print numbers the JavaScript way, so a
document parsed from a pi file serializes back to the same bytes.
Traits§
- Json
Value - A JSON document in memory, whose serialization cannot fail.
Functions§
- js_
number - JavaScript’s
Number(text): surrounding whitespace ignored,0for empty text, unsigned0x,0oand0bintegers,Infinitywith an optional sign, else a decimal literal, andNaNfor anything else. - number
- A JavaScript number as JSON: an integer when it is a safe one, so it compares equal to the same number parsed from a pi file.
- parse
- Parses
textlike pi’sJSON.parse(stripBom(text)): a leading byte order mark is ignored. - stringify
- Serializes a JSON value like
JSON.stringify(value). - to_
string - Serializes
valuelikeJSON.stringify(value). - to_
string_ pretty - Serializes
valuelikeJSON.stringify(value, null, indent).