MultiKeyMap<K, V>.fromJson constructor

MultiKeyMap<K, V>.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory MultiKeyMap.fromJson(Map<String, dynamic> json) {
  if(json == null) return null;
  if(json.containsKey('multi_key_map_items'))
    return MultiKeyMap<K, V>()..items = (
        (json['multi_key_map_items'] as List)
            ?.map((e) =>
        e == null ? null : JMapEntry<K, V>.fromJson(e as Map<String, dynamic>))
            ?.toList()
    );
  List<JMapEntry<K, V>> items = [];
  json.forEach((key, value) {
    if(key != null)
      items.add(JMapEntry<K, V>.fromJson({'key': key, 'value': value}));
  });
  return MultiKeyMap()..items = items;
}