bobzhang/typify/serde_json does not have a README file

    ParseError

    pub(all) suberror ParseError {
    ParseError(message~ : String, line~ : Int, column~ : Int)
    } derive(Eq,
    Debug
    )

    A JSON syntax or range error, mirroring serde_json's error codes and positions (1-based line, column in UTF-8 bytes).
    impl Show for ParseError

    Content

    pub(all) enum Content {
    Null
    Bool(Bool)
    Number(Number)
    String(String)
    Array(Array[Content])
    Object(Array[Entry])
    Invalid(ParseError)
    Float32(Float)
    } derive(Eq,
    Debug
    )

    An ordered JSON document: object entries keep their order and duplicates, numbers keep serde_json's classification. This is the input serde's derived deserializers observe.
    impl Show for Content

    Content::to_string

    fn Content::to_string(self : Content) -> String

    Compact JSON text of a document, identical to serde_json's serializer (entries in order, duplicates preserved).

    Content::to_value

    fn Content::to_value(self : Content) -> Value raise ParseError

    The serde_json Value of a document (duplicate keys: the last wins; keys sorted).

    Entry

    pub(all) struct Entry {
    key : String
    key_escaped : Bool
    key_error : ParseError?
    value : Content
    } derive(Eq,
    Debug
    )

    An object entry; key_escaped records whether the key's source text contained escape sequences (it matters for serde_json's numeric map keys).

    Number

    pub(all) enum Number {
    PosInt(UInt64)
    NegInt(Int64)
    Float(Double)
    } derive(
    Debug
    )

    A JSON number with serde_json's internal classification.

    serde_json (without arbitrary_precision) keeps non-negative integers that fit in u64 as PosInt, negative integers that fit in i64 as NegInt, and everything else as a finite Float. The classification is observable: 1 and 1.0 are different values and only the former is an integer.
    impl Eq for Number
    impl Show for Number

    Number::as_f64

    fn Number::as_f64(self : Number) -> Double

    Any number converts to f64 (possibly losing precision), like serde_json.

    Number::as_i64

    fn Number::as_i64(self : Number) -> Int64?

    Number::as_u64

    fn Number::as_u64(self : Number) -> UInt64?

    Number::from_f64

    fn Number::from_f64(d : Double) -> Number?

    Build a number from a finite f64; returns None for NaN or infinities.

    Number::from_i64

    fn Number::from_i64(n : Int64) -> Number

    Build a number from an i64, normalising non-negative values to PosInt like serde_json's From<i64>.

    Number::from_u64

    fn Number::from_u64(n : UInt64) -> Number

    Build a number from a u64.

    Number::is_f64

    fn Number::is_f64(self : Number) -> Bool

    Number::is_i64

    fn Number::is_i64(self : Number) -> Bool

    Number::is_u64

    fn Number::is_u64(self : Number) -> Bool

    Number::to_string

    fn Number::to_string(self : Number) -> String

    Render like serde_json's Display for Number (itoa / ryu).

    Value

    pub(all) enum Value {
    Null
    Bool(Bool)
    Number(Number)
    String(String)
    Array(Array[Value])
    Object(
    StrMap
    [Value])
    } derive(Eq,
    Debug
    )

    A JSON value with serde_json semantics: numbers keep their integer/float classification and objects iterate in key order (serde_json without the preserve_order feature, as used by typify).
    impl Show for Value

    Value::as_array

    fn Value::as_array(self : Value) -> Array[Value]?

    Value::as_bool

    fn Value::as_bool(self : Value) -> Bool?

    Value::as_f64

    fn Value::as_f64(self : Value) -> Double?

    Like serde_json's as_f64: any number converts, other values do not.

    Value::as_i64

    fn Value::as_i64(self : Value) -> Int64?

    Value::as_object

    Value::as_str

    fn Value::as_str(self : Value) -> String?

    Value::as_u64

    fn Value::as_u64(self : Value) -> UInt64?

    Value::from_f64

    fn Value::from_f64(d : Double) -> Value

    Non-finite floats become Null, like serde_json's From<f64>.

    Value::from_i64

    fn Value::from_i64(n : Int64) -> Value

    Value::from_json

    fn Value::from_json(json : Json) -> Value

    Convert from MoonBit's builtin Json. Numbers with a preserved lexeme are re-classified from it; otherwise integral values within 2^53 become integers and everything else a float.

    Value::from_u64

    fn Value::from_u64(n : UInt64) -> Value

    Value::get

    fn Value::get(self : Value, key : StringView) -> Value?

    Look up a key of an object value.

    Value::is_array

    fn Value::is_array(self : Value) -> Bool

    Value::is_boolean

    fn Value::is_boolean(self : Value) -> Bool

    Value::is_f64

    fn Value::is_f64(self : Value) -> Bool

    Value::is_i64

    fn Value::is_i64(self : Value) -> Bool

    Value::is_null

    fn Value::is_null(self : Value) -> Bool

    Value::is_number

    fn Value::is_number(self : Value) -> Bool

    Value::is_object

    fn Value::is_object(self : Value) -> Bool

    Value::is_string

    fn Value::is_string(self : Value) -> Bool

    Value::is_u64

    fn Value::is_u64(self : Value) -> Bool

    Value::object

    fn Value::object(pairs : ArrayView[(String, Value)]) -> Value

    Build an object value from pairs (later duplicates win).

    Value::to_content

    fn Value::to_content(self : Value) -> Content

    The ordered document of a Value (keys in sorted order).

    Value::to_json

    fn Value::to_json(self : Value) -> Json

    Convert to MoonBit's builtin Json. Integers outside the exactly representable range keep their text in repr.

    Value::to_string

    fn Value::to_string(self : Value) -> String

    Value::to_string_pretty

    fn Value::to_string_pretty(self : Value) -> String

    Pretty JSON text, identical to serde_json's to_string_pretty.

    format_f32

    fn format_f32(f : Float) -> String

    Format a finite f32 exactly like serde_json 1.0.151's float writer (zmij: shortest round-trip digits for f32, plain notation for decimal exponents in -6..=12, otherwise d.ddde±x).

    format_f64

    fn format_f64(d : Double) -> String

    Format a finite f64 exactly like serde_json 1.0.151's float writer (ryu's shortest digits and layout, with e+ for positive exponents).

    parse

    fn parse(text : StringView) -> Value raise ParseError

    Parse JSON text exactly like serde_json::from_str::<Value>, including its error messages and positions.

    parse_content

    fn parse_content(text : StringView, lenient? : Bool) -> Content raise ParseError

    Parse JSON text into an ordered document that keeps duplicate keys, number classes and key-escape information (serde's Content view of the input).

    write_escaped_str

    fn write_escaped_str(buf : StringBuilder, s : StringView) -> Unit

    Write a JSON string literal with serde_json's escaping rules: only ", \ and control characters are escaped; everything else is emitted as-is.