isJSON method

bool isJSON(
  1. String value
)

Checks if the string is a valid JSON format.

Parameters:

  • value The string to be checked.

Returns:

A boolean indicating whether the string is valid JSON.

Implementation

bool isJSON(String value) {
  try {
    jsonDecode(value);
    return true;
  } catch (e) {
    return false;
  }
}