toJSON method

  1. @override
int? toJSON()
override

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;
}