ObjectMapper 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
Implementers

Constructors

ObjectMapper()
Creates a new instance of the default Jetson ObjectMapper implementation.
factory

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.
enableFeature(String featureName) → void
Enables a configurable feature flag within the mapping engine.
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readValue<T>(String data, Class<T> type, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → T
Deserializes a structured string into an object of type T.
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.
registerAdapter(Class type, ObjectSerializationAdapter<dynamic, Generator, Parser, DeserializationContext<Parser>, SerializationContext<Generator>> adapter) → void
Registers a bidirectional adapter (ObjectSerializationAdapter) for type T.
registerDeserializer(Class type, ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>> deserializer) → void
Registers a custom deserializer for type T.
registerSerializer(Class type, ObjectSerializer<dynamic, Generator, SerializationContext<Generator>> serializer) → void
Registers a custom serializer for type T.
setDeserializationContext(DeserializationContext<Parser> context) → void
Assigns the DeserializationContext used during deserialization.
setNamingStrategy(NamingStrategy strategy) → void
Sets the active NamingStrategy for this mapper.
setSerializationContext(SerializationContext<Generator> context) → void
Assigns the SerializationContext used during serialization.
toString() → String
A string representation of this object.
inherited
writeValueAsMap(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → Map<String, dynamic>
Serializes a Dart object into a Map<String, dynamic> representation.
writeValueAsString(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → String
Serializes a Dart object into a structured format string.

Operators

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

Constants

INDENT_SIZE → const String
Configuration property key that controls the number of spaces used when pretty-printing structured output.
TIMEZONE_PROPERTY → const String
The configuration key for specifying the default timezone used by Jetson.