JsonDeserializationContext class
Default implementation of DeserializationContext in Jetleaf’s JSON subsystem.
The JsonDeserializationContext acts as the central deserialization registry for the ObjectMapper. It is responsible for locating, caching, and invoking the correct ObjectDeserializer for a given type during JSON-to-object conversion.
Responsibilities
- Manage user-defined and framework-provided deserializers.
- Resolve ObjectDeserializer instances dynamically based on type compatibility.
- Provide fallback to generic
DartJsonDeserializerwhen no specific handler exists. - Integrate with the ObjectMapper for consistent naming, type conversion, and environment configuration.
Deserializer Resolution Flow
- Attempt lookup in user-configured deserializers.
- Fallback to framework-level deserializers.
- Match by type or deserialization capability (
canDeserialize). - Create a
DartJsonDeserializerif no match is found and cache it for future use.
Example
final context = JsonDeserializationContext(objectMapper, {});
final user = context.deserialize(parser, Class.forType(User));
See also
- ObjectDeserializer
- ObjectMapper
- DeserializationContext
DartJsonDeserializer
- Implemented types
Constructors
-
JsonDeserializationContext(ObjectMapper _objectMapper, Map<
Class, ObjectDeserializer< _deserializers)dynamic, Parser, DeserializationContext< >Parser> > - Creates a new JsonDeserializationContext associated with the given ObjectMapper.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
deserialize<
T> (JsonParser parser, Class< T> type) → T -
Deserializes an object of type
Tfrom the current Parser<Token> state.override -
find(
Class type, Map< Class, ObjectDeserializer< deserializers) → ObjectDeserializer<dynamic, Parser, DeserializationContext< >Parser> >dynamic, Parser, DeserializationContext< ?Parser> > -
Attempts to locate a ObjectDeserializer for the specified
typewithin the givendeserializersmap. -
findDeserializerForType(
Class type) → ObjectDeserializer< dynamic, Parser, DeserializationContext< ?Parser> > -
Locates a registered ObjectDeserializer capable of handling the given
type.override -
getConversionService(
) → ConversionService -
Returns the global
ConversionServiceresponsible for type coercions and primitive value conversions.override -
getEnvironment(
) → Environment -
Returns the active
Environmentconfiguration associated with this mapper.override -
getNamingStrategy(
) → NamingStrategy -
Returns the naming strategy used for field name conversion.
override
-
getObjectMapper(
) → ObjectMapper -
Returns the active ObjectMapper performing serialization.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited