isJson function

bool isJson(
  1. String str
)

check if the string is valid JSON

Implementation

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