isJson property

bool get isJson

Checks if the string is valid JSON.

Uses Dart's JsonDecoder to validate if the string can be parsed as proper JSON. Empty strings are considered invalid JSON.

Returns true if the string contains valid JSON, otherwise returns false.

Example:

'{"name":"John", "age":30}'.isJson; // true
'[1, 2, 3]'.isJson; // true
'"hello"'.isJson; // true (valid JSON string)
'{ invalid json }'.isJson; // false
''.isJson; // false (empty string)

Implementation

bool get isJson {
  return _isJson(this);
}