Trying to save and restore a map of custom objects ... and not succeeding.
I have a custom object defined as something like this in an include script :
function CustomObject(name, value1, ...) {
this.name = name;
this.someProperty = value1;
this.someMethod = function() { DOpus.Output(this.someProperty); };
// ...
}
In another script, I am trying to save a map of those custom objects (DOpus.Vars.Set and DOpus.Vars("myMapVarName").persist = true;).
The map gets saved, I can get it back (sort of) : I get the proper length and can use Map methods on it.
But, when I try to enumerate the map and get each element, I don't seem to be getting back my custom object :
- I can't access properties
- The DOpus.TypeOf of the retrieved object is unknown
- If I check (via instanceof) the type of the retrieved object, it does not match CustomObject
- JSON.stringify returns undefined (whereas working on object in the map before saving).
Note : my uservars.oxc looke like this (and the map is CommonLoggerConfig) :
<?xml version="1.0" encoding="UTF-8"?>
<uservars>
<CommonLoggerConfig map="yes" size="2" type="9">
<elements />
</CommonLoggerConfig>
<EverythingDopusCLI path="yes" string="C:\ZZ_PORTABLE_SOFTWARE_x64\EverythingDopus\ed.exe" type="9" />
</uservars>
Since persisting Maps was added (as reported here), I add the hope it would be also extended to custom object types ... it looks like I got carried away
Any clue as to what would be the best way to persist custom objects ?
Maybe having an inside mechanism to serialize/deserialize ?
Many thanks for any insight.