isJson method

bool isJson()

Returns true if the string can be parsed as a JSON object, false otherwise.

Implementation

bool isJson() {
  try {
    jsonDecode(this);
    return true;
  } on FormatException catch (_) {
    return false;
  }
}