The other way of using
TCollection kind of parameters is to
declare it explicitly to the framework. You should call
JSONSerializer.RegisterCollectionForJSON() with the corresponding
TCollection / TCollectionItem class type pair.
Consider a dedicated class:
TMyCollection = type(TCollection)
Note that a dedicated type is needed here. You just can't use this
registration over a plain
Then, for instance, after calling:
The following lines of code are the same:
MyColl := TMyCollection.Create(TMyCollection); MyColl := ClassInstanceCreate(TMyCollection) as TMyCollection; MyColl := ClassInstanceCreate('TMyCollection') as TMyCollection;
Thanks to this internal registration table, mORMot will be able to
serialize and unserialize plain
TCollection type, without the need
of inheriting from a dedicated type.
Feedback is welcome on our forum.