You are not logged in.
Pages: 1
Hello!
Is there any possibility to perform custom TSQLRecord serialization?
The problem is that I need to map my Model's properties names to different names. For example in my Model I have published property "Name" and as a result I get such a JSON on certain REST server call: {"Name": "test"}. But I need to have a possibility to change this property name to get something like {"_name": "test"}. I tried to use TJSONSerializer.RegisterCustomSerializer(TMySQLRecord, nil, TMySQLRecord.FVClassWriter); but custom serialization method is not called on REST request. Custom serialization methos is called only on explicity ObjectToJson function call.
Many thanks in advanced!
Offline
No, TSQLRecord should have direct serialization of published properties, maybe via getter/setter.
JSON serialization is used internally by the ORM, even without any REST remote access.
What you can do is define the table as external, use a SynDBSQLite3 connection, and define a custom mapping.
Another way - which I would fell better - is to define a custom REST service (using a method-based service or an interface-based service) returning the expected data.
Offline
Pages: 1