fromJsonMapT<K, T> method

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

json数据转Map对象

Implementation

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