jsonMap<V> method
Converts this string to Map<String, T>
using the converter function
fromJson
Implementation
Map<String, V> jsonMap<V>(V Function(Map<String, dynamic>) fromJson) {
final json = jsonDecode(this);
if (json is Map) {
final result = <String, V>{};
for (final key in json.keys) {
if (key is String) {
final value = json[key];
if (value is Map) {
final v = value.json(fromJson);
result[key] = v;
} else {
throw ArgumentError(
'The decoded value type with key \'$key\ is not a \'Map\': ${key.runtimeType}');
}
} else {
throw ArgumentError(
'The decoded key type is not a \'String\': ${key.runtimeType}');
}
}
return result;
}
throw ArgumentError(
'The decoding result type is not a \'Map\': ${json.runtimeType}');
}