fromJson static method
Return a request parsed from the given json, or null
if the data
is
not a valid json representation of a request. The data
is expected to
have the following format:
{ 'clientRequestTime': millisecondsSinceEpoch 'id': String, 'method': methodName, 'params': { parameter_name: value } }
where both the parameters and clientRequestTime are optional.
The parameters can contain any number of name/value pairs. The clientRequestTime must be an int representing the time at which the client issued the request (milliseconds since epoch).
Implementation
static Request? fromJson(Map<String, Object?> result) {
var id = result[Request.ID];
var method = result[Request.METHOD];
if (id is! String || method is! String) {
return null;
}
var time = result[Request.CLIENT_REQUEST_TIME];
if (time is! int?) {
return null;
}
var params = result[Request.PARAMS];
if (params is Map<String, Object?>?) {
return Request(id, method, params, time);
} else {
return null;
}
}