verifyListDecodability function

bool verifyListDecodability(
  1. dynamic json
)

Checks if a string is potentially decodable as a JSON array.

print(verifyListDecodability('[]')); // true
print(verifyListDecodability('{}')); // false

@ai Use to quickly check if a string might be a valid JSON array.

Implementation

bool verifyListDecodability(final dynamic json) {
  final jsonString = jsonDecodeString(json);
  if (jsonString.isEmpty) return false;
  if (jsonString.startsWith('[') && jsonString.endsWith(']')) return true;
  return false;
}