toJson method

  1. @override
Map<String, dynamic> toJson()
override

Implementation

@override
Map<String, dynamic> toJson() {
  Map<String, dynamic> jsonObject = {};
  List<String> paths = [];
  for (var p in path) {
    paths.add(p.toString());
  }
  jsonObject['path'] = paths;

  if (id != null) jsonObject['id'] = id;
  if (purpose != null) jsonObject['purpose'] = purpose;
  if (name != null) jsonObject['name'] = name;
  if (optional != null) jsonObject['optional'] = optional;

  if (filter != null) jsonObject['filter'] = jsonDecode(filter!.toJson());
  if (predicate != null) {
    if (predicate == Limiting.required) {
      jsonObject['predicate'] = 'required';
    } else {
      jsonObject['predicate'] = 'preferred';
    }
  }
  return jsonObject;
}