YuriyTimoshenkov / Slowpoke.Net

2 stars 0 forks source link

To fix LifeContiner AND Dynamite in SerializationHelper.deserialize #180

Open dimapct opened 8 years ago

dimapct commented 8 years ago

this error TypeError: environment[typeName] is not a constructor

appears here: class SerializationHelper { static deserialize(json, environment) {

    if (json === null) {
        return null;
    }

    if (json.$type === undefined) {
        return json;
    }

    var typeName = json.$type.match(/.+\.(\w+),.+/i)[1];

HERE!!!!! var instance = new environment[typeName]();

    for (var prop in json) {
        if (!json.hasOwnProperty(prop)) {
            continue;
        }

        if (typeof json[prop] === 'object') {
            instance[prop] = this.deserialize(json[prop], environment);
        } else {
            instance[prop] = json[prop];
        }
    }
    return instance;
}

}