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 DartJsonDeserializer when no specific handler exists.
  • Integrate with the ObjectMapper for consistent naming, type conversion, and environment configuration.

Deserializer Resolution Flow

  1. Attempt lookup in user-configured deserializers.
  2. Fallback to framework-level deserializers.
  3. Match by type or deserialization capability (canDeserialize).
  4. Create a DartJsonDeserializer if 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

Implemented types

Constructors

JsonDeserializationContext(ObjectMapper _objectMapper, Map<Class, ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>>> _deserializers)
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 T from the current Parser<Token> state.
override
find(Class type, Map<Class, ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>>> deserializers) → ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>>?
Attempts to locate a ObjectDeserializer for the specified type within the given deserializers map.
findDeserializerForType(Class type) → ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>>?
Locates a registered ObjectDeserializer capable of handling the given type.
override
getConversionService() → ConversionService
Returns the global ConversionService responsible for type coercions and primitive value conversions.
override
getEnvironment() → Environment
Returns the active Environment configuration 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