isJson property

bool get isJson

Checks if this string is a valid JSON string.

Example: '{"name": "John", "age": 30}'.isJson -> true.

Implementation

bool get isJson {
  if (isBlank) return false;
  try {
    jsonDecode(this);
    return true;
  } catch (_) {
    return false;
  }
}