decodeJsonObject function
- String? body
body as a JSON object, or null for no body, malformed JSON or any other JSON value.
Implementation
Map<String, dynamic>? decodeJsonObject(String? body) {
if (body == null) {
return null;
}
try {
final json = jsonDecode(body);
return json is Map<String, dynamic> ? json : null;
} on FormatException {
return null;
}
}