toJSON method
Converts the integer field to a JSON-compatible format.
Returns the underlying rawValue, which can be an int
or null
.
This method is used during serialization to include the field in the JSON output.
Example:
JsonInteger ageField = JsonInteger("age");
ageField.value = 25;
Map<String, dynamic> json = {"age": ageField.toJSON()}; // {"age": 25}
Implementation
@override
int? toJSON() {
return rawValue;
}