isJson function

bool isJson(
  1. String str
)

Returns true if str is valid JSON.

Implementation

bool isJson(String str) {
  try {
    jsonDecode(str);
    return true;
  } catch (_) {
    return false;
  }
}