Register a custom serializer for a type. Allows you to provide a custom serializer implementation for a specific type, overriding Fory's default serialization behavior. Args: cls: The Python type to associate with the serializer serializer:
(self, cls: type, serializer)
| 353 | ) |
| 354 | |
| 355 | def register_serializer(self, cls: type, serializer): |
| 356 | """ |
| 357 | Register a custom serializer for a type. |
| 358 | |
| 359 | Allows you to provide a custom serializer implementation for a specific type, |
| 360 | overriding Fory's default serialization behavior. |
| 361 | |
| 362 | Args: |
| 363 | cls: The Python type to associate with the serializer |
| 364 | serializer: Custom serializer instance implementing the Serializer protocol |
| 365 | |
| 366 | Example: |
| 367 | >>> fory = Fory(xlang=False) |
| 368 | >>> fory.register_serializer(MyClass, MyCustomSerializer()) |
| 369 | """ |
| 370 | self.type_resolver.register_serializer(cls, serializer) |
| 371 | |
| 372 | def dumps( |
| 373 | self, |