fromJson method
Creates a Document instance from json
.
The instance may be a MetaDocument, a DataDocument, or an ErrorDocument
depending on the json
. If json
does not match any of the above,
a CastError
is thrown.
Implementation
static Document fromJson(Map<String, dynamic> json) {
final links = json['links'];
final self = links != null ? Link.fromJson(links['self']) : null;
if (json.containsKey('meta')) {
return MetaDocument(json['meta'],
api: Api.fromJson(json['jsonapi']), self: self);
}
throw CastError();
}