serialize method

  1. @override
void serialize(
  1. Url value,
  2. G generator,
  3. SC serializer
)
override

Serializes an object of type T into an object using the provided Generator and SerializationContext.

Implementations should:

  • Write fields in the correct an object structure using generator
  • Apply the active NamingStrategy for key transformation
  • Use the SerializationContext for nested or custom serialization

Example

serializer.serialize(user, generator, provider);
final json = generator.toJsonString();
print(json); // {"id":1,"name":"Alice"}

Notes

  • Should write valid an object output
  • May recursively serialize nested objects
  • Must maintain structural integrity of objects and collections

Error Handling

Implementations should throw descriptive errors if:

  • A required field cannot be serialized
  • An unsupported type is encountered
  • an object structural consistency cannot be guaranteed

See also

Implementation

@override
void serialize(Url value, G generator, SC serializer) {
  generator.writeString(value.toString());
}