fromJson<T> static method

T? fromJson<T>(
  1. TypeCode? type,
  2. String value
)

Converts JSON string into a value of type specified by a TypeCode.

  • type the TypeCode for the data type into which 'value' is to be converted.
  • value the JSON string to convert. Returns converted object value or null when value is null.

Implementation

static T? fromJson<T>(TypeCode? type, String value) {
  try {
    var temp = jsonDecode(value);
    return TypeConverter.toType<T>(type, temp);
  } catch (e) {
    return null;
  }
}