fromJsonMapListT<K, T> method

Map<K, List<T>?>? fromJsonMapListT<K, T>(
  1. T fromJsonT(
    1. dynamic json
    )
)

json数据转Map集合对象

Implementation

Map<K, List<T>?>? fromJsonMapListT<K, T>(T Function(dynamic json) fromJsonT) {
  var str = this;
  if (str == null || str.isEmpty) {
    return null;
  }
  Map map = jsonDecode(str);
  var newMap = <K, List<T>?>{};
  map.forEach((key, value) {
    if (value == null) {
      newMap[key] = null;
    } else {
      List list = json.decode(value);
      newMap[key] = list.map((value) {
        return fromJsonT(value);
      }).toList();
    }
  });
  return newMap;
}