parseBodyWithConverter<T> function
Parse JSON body with custom type conversion
Implementation
T? parseBodyWithConverter<T>(List<int> bytes, JsonConverter<T> converter) {
var body = utf8.decode(bytes);
// Decode JSON
var decoded = json.decode(body);
try {
// Apply converter to decoded JSON
return converter(decoded);
} catch (e) {
throw FormatException('Failed to convert JSON to type $T: ${e.toString()}');
}
}