Map<String, dynamic> toJson() { final unit = this.unit; final value = this.value; return { if (unit != null) 'Unit': unit.toValue(), if (value != null) 'Value': value, }; }