JsonObjectMapper class abstract interface

Provides a unified abstraction for object serialization and deserialization within the Jetleaf framework.

The ObjectMapper serves as the central entry point for converting between Dart objects and their JSON (or Map<String, dynamic>) representations. It respects naming strategies, annotations, and registered converters, enabling consistent and extensible data mapping.

Core Responsibilities

  • Serialize objects to JSON strings or maps
  • Deserialize JSON data into strongly typed Dart objects
  • Manage custom serializers, deserializers, and adapters
  • Apply naming strategies and type coercion via ConversionService

Example

final mapper = DefaultObjectMapper();
mapper.setNamingStrategy(SnakeCaseNamingStrategy());

final user = User(name: 'Alice', age: 30);
final json = mapper.writeValueAsString(user);

final restored = mapper.readValue<User>(json, Class<User>());

Extensibility

See also

Implemented types

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

disableFeature(String featureName) → void
Disables a configurable feature flag.
inherited
enableFeature(String featureName) → void
Enables a configurable feature flag within the mapping engine.
inherited
getConversionService() → ConversionService
Returns the global ConversionService responsible for type coercions and primitive value conversions.
inherited
getEnvironment() → Environment
Returns the active Environment configuration associated with this mapper.
inherited
getNamingStrategy() → NamingStrategy
Returns the naming strategy used for field name conversion.
inherited
isFeatureEnabled(String featureName) → bool
Returns whether a feature flag is currently enabled.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readContentTree(String content) → JsonNode
Parses the given JSON content string into a JsonNode tree.
readJsonValue<T>(String data, Class<T> type) → T
Deserializes a structured json string into an object of type T.
readJsonValueFromMap<T>(Map<String, dynamic> map, Class<T> type) → T
Deserializes a pre-parsed map into an object of type T.
readTree(JsonParser parser) → JsonNode
Reads and parses JSON content from the given JsonParser into a JsonNode tree.
readValue<T>(String data, Class<T> type, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → T
Deserializes a structured string into an object of type T.
inherited
readValueFromMap<T>(Map<String, dynamic> map, Class<T> type, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → T
Deserializes a pre-parsed map into an object of type T.
inherited
registerAdapter(Class type, ObjectSerializationAdapter<dynamic, Generator, Parser, DeserializationContext<Parser>, SerializationContext<Generator>> adapter) → void
Registers a bidirectional adapter (ObjectSerializationAdapter) for type T.
inherited
registerDeserializer(Class type, ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>> deserializer) → void
Registers a custom deserializer for type T.
inherited
registerSerializer(Class type, ObjectSerializer<dynamic, Generator, SerializationContext<Generator>> serializer) → void
Registers a custom serializer for type T.
inherited
setDeserializationContext(DeserializationContext<Parser> context) → void
Assigns the DeserializationContext used during deserialization.
inherited
setJsonGenerator(JsonGenerator generator) → void
Sets the active JsonGenerator used for serializing Dart objects to JSON.
setNamingStrategy(NamingStrategy strategy) → void
Sets the active NamingStrategy for this mapper.
inherited
setSerializationContext(SerializationContext<Generator> context) → void
Assigns the SerializationContext used during serialization.
inherited
toString() → String
A string representation of this object.
inherited
writeValueAsJson(Object? value) → String
Serializes a Dart object into a JSON string.
writeValueAsJsonMap(Object? value) → Map<String, dynamic>
Serializes a Dart object into a Map<String, dynamic> representation.
writeValueAsMap(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → Map<String, dynamic>
Serializes a Dart object into a Map<String, dynamic> representation.
inherited
writeValueAsString(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → String
Serializes a Dart object into a structured format string.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited