ejson library

Classes

DBRef<KeyT>
See DBRef This is not technically a BSON type, but a common convention.
Defined<T>
EJson<T>
Annotation to mark a class for extended json (ejson) serialization
Undefined<T>
UndefinedOr<T>

Constants

ejson → const EJson
Annotation to mark a class for extended json (ejson) serialization
undefined → const Undefined

Properties

commonDecoders Map<Type, Function>
Predefined decoders for common types
final
relaxed bool
Whether to use relaxed encoding or not, default is false
getter/setter pair

Functions

fromEJson<T>(EJsonValue? ejson, {T? defaultValue}) → T
Converts ejson to type T.
fromEJsonString<T>(String source) → T
Parses source to EJsonValue and convert to type T.
register<T>(EJsonEncoder<T> encoder, EJsonDecoder<T> decoder, {Iterable<Type>? superTypes}) → void
Register custom EJSON encoder and decoder for a type T. The last registered codec pair for a given type T will be used.
toEJson(Object? value) EJsonValue?
Converts value to EJson
toEJsonString(Object? value) String
Converts value to EJson string

Typedefs

EJsonDecoder<T> = T Function(EJsonValue? ejson)
EJsonEncoder<T> = EJsonValue? Function(T object)
EJsonValue = Object?

Exceptions / Errors

InvalidEJson
Thrown when a value cannot be decoded from ejson.
MissingDecoder
Thrown when no decoder is registered for a type.
MissingEncoder
Exception thrown when no encoder is registered for the type of a value.