ObjectJsonSerializer

Custom JSON converter for serializing and deserializing objects of type T (Object).

Remarks

This JSON converter handles special cases, such as serializing and deserializing objects derived from Asset, and allows dynamic serialization and deserialization of object properties and fields. Polymorphism is handled via stable Guid ids declared with TypeIdAttribute and resolved through TypeRegistry, so serialized data survives renames and namespace changes.

Fields

TypeIdProperty (string) = "__TypeId": Property name carrying the stable type id (a Guid) for polymorphic dispatch.

Public Methods

Read

public override T Read(Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters:

  • reader (Utf8JsonReader)
  • typeToConvert (Type)
  • options (JsonSerializerOptions)

Returns: T

Write

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)

Parameters:

  • writer (Utf8JsonWriter)
  • value (T)
  • options (JsonSerializerOptions)