You are not logged in.
Pages: 1
When streaming an object to Json, using
ObjectToJson(C, [woDontStoreDefault,woRawBlobAsBase64,woDontStoreVoid])
I ran into a problem, when a property is of type TObjectList.
Result: (Contained is published r/w property of type TObjectList:
// [woDontStoreDefault,woRawBlobAsBase64,woDontStoreVoid]
{"One":{"Name":"G"},"ID":42}
// [woDontStoreDefault,woRawBlobAsBase64]
{"One":{"Name":"G"},"ID":42,"Contained":[{"ClassName":"TOne","Name":"W"}]}
As soon as I omit woDontStoreVoid, it'll work just fine.
However, as I am trying to go through TInterfacedObjectFakeRaw.FakeCall -> TInterfacedObjectFake.FakeCallInternalProcess -> TInterfacedObjectFake.FakeCallGetJsonFromStack -> TInterfaceMethodArgument.AddJson (mocking in tests), Icannot control those parameters...
Regards,
Daniel
P.S.: A simple test project for this: https://filetransfer.io/data-package/C20KDkoc#link
Last edited by sakura (2024-04-23 11:11:35)
Offline
The documentation and source code states that plain TObjectList can be persisted into JSON, but not from JSON.
Because there is no way to know how to create the TObject instances when populating the list from JSON.
So TObjectList are not allowed as parameters of interface based services.
Use T*ObjArray or TCollections or other types of parameters, like plain RawJson or an array of records.
Offline
But it does work perfectly, when woDontStoreVoid is not part of the set. So, why do you write, that it is not possible? Even that part "from JSON". Have used it in other places before - without the woDontStoreVoid Attribute, never had a problem...
P.S.: I use it for places, where I cannot predetermine the type of object, that is going to be encountered. So a T*ObjArray wouldn't work, just a TCollections don't work, as all are tied to a single collection type.
Last edited by sakura (2024-04-24 04:52:25)
Offline
My bad, I didn't see that the "classname" property is used with the JSON content to store each item class.
Now I understand.
Please try:
https://github.com/synopse/mORMot2/commit/2889f04d
Offline
Pages: 1