toJson method
Serializes Grid into a json Map
Implementation
Map<String, dynamic> toJson() {
final jsonMap = {
'id': id,
'name': name,
if (key != null) 'key': key,
if (rows != null) 'entities': rows!.map((e) => e.toJson()).toList(),
if (fields != null) 'fields': fields!.map((e) => e.toJson()).toList(),
if (hiddenFields != null)
'hiddenFields': hiddenFields!.map((e) => e.toJson()).toList(),
if (filter != null) 'filter': filter,
if (sorting != null) 'sorting': sorting,
'_links': links.toJson(),
};
if (embeddedForms != null) {
final embeddedMap =
jsonMap['_embedded'] as Map<String, dynamic>? ?? <String, dynamic>{};
embeddedMap['forms'] = embeddedForms?.map((e) => e.toJson()).toList();
jsonMap['_embedded'] = embeddedMap;
}
return jsonMap;
}