Extends the ObjectMapper interface to provide specialized support for XML serialization and deserialization.
The XmlObjectMapper builds upon the base ObjectMapper contract by adding XML-specific methods for reading and writing Dart objects in XML format. It maintains full compatibility with the standard JSON mapper interface while providing XML-focused operations.
Core Methods
- readXmlValue - Deserializes XML string to Dart object
- readXmlValueFromMap - Deserializes XML map to Dart object
- readXmlTree - Parses XML string to XmlNode tree
- writeValueAsXml - Serializes Dart object to XML string
- writeValueAsXmlMap - Serializes Dart object to XML map
Design Notes
- Inherits all JSON serialization methods from ObjectMapper
- XML-specific methods follow the same naming patterns as JSON counterparts
- Supports both tree-based (DOM) and streaming (SAX-like) XML processing
- Integrates with Jetson's naming strategies and converters
Example
final mapper = XmlObjectMapper();
// Serialization
final user = User(id: 1, name: 'Alice');
final xml = mapper.writeValueAsXml(user);
// Output: <user><id>1</id><name>Alice</name></user>
// Deserialization
final restored = mapper.readXmlValue<User>(xml, Class<User>());
Related Interfaces
- ObjectMapper - Base serialization/deserialization contract
- YamlObjectMapper - YAML-specific operations
- XmlNode - XML DOM tree representation
- Implemented types
- Implementers
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
ConversionServiceresponsible for type coercions and primitive value conversions.inherited -
getEnvironment(
) → Environment -
Returns the active
Environmentconfiguration 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
-
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 -
readXmlContentTree(
String content) → XmlNode -
Parses the given XML
contentstring into an XmlNode tree. -
readXmlTree(
XmlParser parser) → XmlNode - Reads and parses XML content from the given XmlParser into an XmlNode tree.
-
readXmlValue<
T> (String xml, Class< T> type) → T -
Deserializes an XML string into an object of type
T. -
readXmlValueFromMap<
T> (Map< String, dynamic> map, Class<T> type) → T -
Deserializes an XML-compatible map into an instance of type
T. -
registerAdapter(
Class type, ObjectSerializationAdapter< dynamic, Generator, Parser, DeserializationContext< adapter) → voidParser> , SerializationContext<Generator> > -
Registers a bidirectional adapter (
ObjectSerializationAdapter) for typeT.inherited -
registerDeserializer(
Class type, ObjectDeserializer< dynamic, Parser, DeserializationContext< deserializer) → voidParser> > -
Registers a custom deserializer for type
T.inherited -
registerSerializer(
Class type, ObjectSerializer< dynamic, Generator, SerializationContext< serializer) → voidGenerator> > -
Registers a custom serializer for type
T.inherited -
setDeserializationContext(
DeserializationContext< Parser> context) → void -
Assigns the DeserializationContext used during deserialization.
inherited
-
setNamingStrategy(
NamingStrategy strategy) → void -
Sets the active NamingStrategy for this mapper.
inherited
-
setSerializationContext(
SerializationContext< Generator> context) → void -
Assigns the SerializationContext used during serialization.
inherited
-
setXmlGenerator(
XmlGenerator generatorr) → void - Sets the active XmlGenerator used for serializing Dart objects to XML.
-
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.inherited -
writeValueAsString(
Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → String -
Serializes a Dart object into a structured format string.
inherited
-
writeValueAsXml(
Object? value) → String - Serializes a Dart object into an XML string.
-
writeValueAsXmlMap(
Object? value) → Map< String, dynamic> -
Serializes a Dart object into an XML
Map<String, dynamic>representation.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited