toJson method Null safety

Map toJson()

Implementation

Map toJson(){
  Map result = {};

  if (data != null) result.addAll({"data": data});
  if (friendlyName != null) result.addAll({"friendlyName": friendlyName});
  if (attributes != null) result.addAll({"attributes": attributes});

  return result;
}