asBean<T> method

T? asBean<T>(
  1. String key,
  2. dynamic toBean(
    1. Map<String, dynamic> json
    ), {
  3. bool decode = false,
})

Implementation

T? asBean<T>(String key, Function(Map<String, dynamic> json) toBean, {bool decode = false}) {
  try {
    if (decode && this[key] != null && this[key] != 'null') {
      return toBean(json.decode(this[key]));
    }
    if (this[key] != null && _isClassBean(this[key])) {
      return toBean(this[key]);
    }
  } catch (e) {
    _print('json 解析异常,异常值:"$key":${this[key]}');
  }
  return null;
}