isJson static method

bool isJson(
  1. String? content
)

输入字符串是否是JSON

Implementation

static bool isJson(String? content) {
  if (content == null) return false;
  try {
    jsonDecode(content);
  } catch (error) {
    print("input is not json: ${error.toString()}");
    return false;
  }
  return true;
}