verifyMapDecodability function

bool verifyMapDecodability(
  1. dynamic json
)

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

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

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

Implementation

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