tryToJson<T> static method

T? tryToJson<T>(
  1. Object? data, {
  2. Object? reviver(
    1. Object?,
    2. Object?
    )?,
})

Converts a JSON-encoded string to a Dart object represented as a Map if possible.

The input data is a JSON-encoded string. Returns a Map representing the Dart object.

Implementation

static T? tryToJson<T>(Object? data,
    {Object? Function(Object?, Object?)? reviver}) {
  try {
    return toJson<T>(data, reviver: reviver);
  } catch (_) {
    return null;
  }
}