isJson method

bool isJson()

Whether the string is valid JSON (object or array).

Implementation

bool isJson() {
  try {
    final v = jsonDecode(this);
    return v is Map || v is List;
  } catch (_) {
    return false;
  }
}