isJson property

bool get isJson

Checks if the string is a valid JSON.

Example:

print('{"a":1}'.isJson); // true

Implementation

bool get isJson {
  try {
    json.decode(this);
    return true;
  } catch (e) {
    return false;
  }
}