Table of Contents

TJsonConverters Class

Central registry that manages JSON type converters and converter factories.

Remarks

TJsonConverters maintains a cache of IJsonTypeConverter instances keyed by TTypeToken and a list of IJsonConverterFactory objects. When a converter is requested via Find or Get, the registry first checks its cache, then queries each factory in registration order until one produces a converter. Built-in factories for nullable types, dynamic arrays, lists, sets, enumerations, and primitive types are registered automatically during construction.

Syntax

Unit: Bcl.Json.Converters

TJsonConverters = class(TInterfacedObject);

Constructors

Name Description
Create Creates a new converter registry with built-in factories for standard types.

Destructors

Name Description
Destroy Destroys the registry and releases all cached converters and factories.

Methods

Name Description
ObjectCreated Notifies the registry that an object was created during deserialization.
ObjectWritten Notifies the registry that an object was written during serialization.
ChangeNotifyCreated Sets NotifyCreated and returns the previous value.
ChangeNotifyWritten Sets NotifyWritten and returns the previous value.
AddFactory Registers a custom converter factory.
All Iterates over all registered factories, including built-in primitive factories.
Find Finds a converter for the specified type, returning nil if none is available.
Get Returns a converter for the specified type, raising an exception if none is available.

Properties

Name Description
OnObjectProcessed Sets the callback invoked when objects are created or written during processing.
OnConverterCreated Gets or sets the callback invoked when a new converter is created and cached.
ObjectConverter​Factory Returns the factory used to create converters for class types.
ObjectFactory Gets or sets the factory used to create object instances during deserialization.