readYamlValue<T> method

  1. @override
T readYamlValue<T>(
  1. String yaml,
  2. Class<T> type
)
override

Deserializes a YAML string into an object of type T.

The YAML is parsed into an intermediate YamlNode tree, which is then mapped to a Dart object using reflection and configured converters.

Example

final user = mapper.readYamlValue<User>(
  'user:\n  id: 1\n  name: Alice',
  Class<User>()
);

Error Handling

Throws an exception if:

  • The YAML is malformed
  • No deserializer found for type T
  • Required fields are missing

Implementation

@override
T readYamlValue<T>(String yaml, Class<T> type) {
  final parser = getYamlParser(yaml);
  final result = getYamlDeserializationContext().deserialize(parser, type);
  parser.close();

  return result;
}