Allows you to serialize object.
Map<String, dynamic> toJson() => {"type": type, "value": value?.toJson()}.clearNulls();