Sign in

    json_deriving

    deriving JSON serialization and deserialization automatically

    json
    derive
    serialization
    deserialization
    Download zip
    Version
    0.1.2
    License
    Apache-2.0
    Last updated
    11 months ago
    Downloads
    62

    #moonbitlang/json_deriving

    A code generator for JSON (de)serialization for MoonBit.

    Decode

    pub(open) trait Decode {
    decode(Json, Path) -> Self raise DecodeError
    }

    convert json to value
    impl Decode for Bool
    impl Decode for Int
    impl Decode for Int16
    impl Decode for Int64
    impl Decode for UInt
    impl Decode for UInt64
    impl Decode for Float
    impl Decode for Double
    impl Decode for String
    impl Decode for Option[T]
    impl Decode for Result[T, E]
    impl Decode for Array[T]

    Encode

    pub(open) trait Encode {
    #as_free_fn
    encode(Self) -> Json
    }

    convert value to json
    impl Encode for Bool
    impl Encode for Int
    impl Encode for Int16
    impl Encode for Int64
    impl Encode for UInt
    impl Encode for UInt64
    impl Encode for Float
    impl Encode for Double
    impl Encode for String
    impl Encode for Option[T]
    impl Encode for Result[T, E]
    impl Encode for Array[T]

    DecodeError

    pub suberror DecodeError (Path, Json)

    impl Show for DecodeError

    Path

    pub(all) enum Path {
    Root
    Key(Path, String)
    Index(Path, Int)
    }

    impl Eq for Path
    impl Show for Path

    decode

    fn[T : Decode] decode(json : Json, path? : Path) -> T raise DecodeError

    fail

    fn[T] fail(path : Path, json : Json) -> T raise DecodeError

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io