mochi/output
Internal typed JSON value used by the encoder.
Resolvers and field extractors hand Dynamic to the encoder. Rather than
brute-forcing the runtime shape with a cascade of decoders on every node,
we classify once with dynamic.classify and convert into this tree. The
JSON encoder then walks the tree directly — no re-classification, no
re-parsing of its own output for pretty printing, no silent fallbacks
when something doesn’t fit.
Types
pub type EncodeError {
UnsupportedValue(path: String, kind: String)
}
Constructors
-
UnsupportedValue(path: String, kind: String)The encoder hit a
Dynamicvalue whose runtime shape it can’t represent in JSON (a tuple, function, pid, etc).pathis the JSON pointer to the offender,kindisdynamic.classifyof the value.
Values
pub fn from_dynamic(
value: dynamic.Dynamic,
) -> Result(Value, EncodeError)
Convert a Dynamic into the typed value tree, surfacing unsupported
shapes as errors instead of silently dropping them.