atproto_lexicon/decoding
Decode lexicon JSON into the atproto_lexicon/ast types.
Unrecognized keys inside a known def or property are ignored: this
module decodes the keys the spec defines and drops anything else,
rather than collecting them into a passthrough bag or erroring. Every
corpus file used to build this package has zero unrecognized keys, so
the choice costs nothing there; it is a real fidelity gap for
documents carrying vendor extensions or not-yet-spec’d fields, which
would silently lose those keys on a decode/encode round trip. An
unrecognized type discriminator (on a def, property, array item or
params property) is different: that is a shape we cannot represent at
all, so it is a decode error rather than a silent drop.
Types
pub type DecodeError {
MalformedJson(reason: String)
InvalidLexicon(
path: List(String),
expected: String,
found: String,
)
}
Constructors
-
MalformedJson(reason: String) -
InvalidLexicon( path: List(String), expected: String, found: String, )
Values
pub fn decode_dynamic(
data: dynamic.Dynamic,
) -> Result(ast.LexiconDoc, List(DecodeError))
pub fn decode_json(
source: String,
) -> Result(ast.LexiconDoc, List(DecodeError))
pub fn document_decoder() -> decode.Decoder(ast.LexiconDoc)