-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toMap #147
Comments
The documentation promises that in the future, from the
For that reason, I have written a small method that undoes this mess: /// Recreates all Maps and Lists recursively to ensure normal Dart types
dynamic yamlToDart(dynamic value) {
if (value is Map) {
List<MapEntry<String, dynamic>> entries = [];
// we cannot directly use `entries` because `YamlMap` will return Nodes instead of values.
for (final key in value.keys) {
entries.add(MapEntry(key, yamlToDart(value[key])));
}
return Map.fromEntries(entries);
} else if (value is List) {
return List.from(value.map(yamlToDart));
} else {
return value;
}
} this is more of a hack than anything, but it should normalize your types. |
I use this ugly hack: final jsonMap = jsonDecode(jsonEncode(yamlMap)); |
why there is no simple way described, just to convert this YamlDocument into ordinary Map type?
The text was updated successfully, but these errors were encountered: