parse method
Parses the given source
string into a Map<String, dynamic>
.
Implementations must:
- Convert the raw string into structured key-value pairs.
- Return a valid map representation.
- Throw a FormatException if parsing fails due to invalid syntax or unexpected input.
Example:
final config = parser.parse('{"debug": true}');
print(config['debug']); // true
Implementation
@override
Map<String, dynamic> parse(String source) {
try {
final root = _parseRootElement(source.trim());
return root;
} catch (e) {
throw ParserException('Failed to parse XML: $e');
}
}