isJSON static method

bool isJSON(
  1. dynamic str
)

Check if the string is valid JSON

Implementation

static bool isJSON(str) {
  try {
    jsonDecode(str);
  } catch (e) {
    return false;
  }
  return true;
}