#1 Re: mORMot 1 » ObjectToJSON <-> JSONToNewObject error » 2013-03-12 13:32:17

I've got the same problem (using 1.18). I want to read a complex JSON-String, which looks like:

{
        "ClassName":"TMyClass",
        "Name":"MainContainer",
        "MyContainedClassList":
        [
                {
                        "ClassName":"TMyClass",
                        "Name":"Container",
                        "MyContainedClassList":
                        [
                                {
                                        "ClassName":"TMyContainedClass",
                                        "Name": "Name0",
                                },
                                {
                                        "ClassName":"TMyContainedClass",
                                        "Name": "Name1",
                                },
                        ]
                }
        ]
}

The first object of TMyClass ("MainContainer") is created by myself before executing the JSONtoObject-method. The second one ("Container") should be created by the JSONtoObject-method.

In my opinion the problem is in the mORMot.pas:26129

result := aClass.Create

There the constructor of TMyClass should be called to create the MyClass object with its TMyContainedClassList. But it never happens. A base class with a virtual constructor is necessary to do that. aClass itself is a TClass object (class of TObject) which hasn't got a virtual constructor.

Board footer

Powered by FluxBB