JsonParsingException constructor

JsonParsingException(
  1. String message, {
  2. Object? cause,
})

An exception that occurs during JSON parsing.

This exception is thrown when there is an error in parsing a JSON string into a Dart object, or when a Dart object cannot be serialized into a JSON string.

Example

void parseJson(String json) {
  try {
    final object = jsonDecode(json);
  } catch (e) {
    throw JsonParsingException("Failed to parse JSON", cause: e);
  }
}

Implementation

JsonParsingException(String message, {Object? cause}) : super(message, cause: cause);