fromJson static method
Initialize a newly created instance based on the given JSON data.
Implementation
static Response? fromJson(Map<String, Object?> json) {
try {
var id = json[Response.ID];
if (id is! String) {
return null;
}
RequestError? decodedError;
var error = json[Response.ERROR];
if (error is Map) {
decodedError =
RequestError.fromJson(ResponseDecoder(null), '.error', error);
}
Map<String, Object?>? decodedResult;
var result = json[Response.RESULT];
if (result is Map<String, Object?>) {
decodedResult = result;
}
return Response(id, error: decodedError, result: decodedResult);
} catch (exception) {
return null;
}
}