Skip to content

Unable to detect changes on a deserialized array #2

Description

@sdalexandre

When I deserialize an object using the JsonSerializer the type of the array change. When displaying the constructor.name of the array, the name become "bound Array".

And then overriding the push() method for example doesn't work:

const MYTYPE_SERIALIZER = new JsonSerializer(MyType)

console.log(data.myArray.constructor.name); // It display "Array"
let myType = MYTYPE_SERIALIZER.deserialize(data, true);
console.log(myType .myArray.constructor.name); // It display "bound Array"

let myArray = myType.myArray;
myArray.push = function () {
        console.log("Debug");
        return Array.prototype.push.apply(this, arguments);
}
myArray.push("Something"); // The console.log("Debug") will not be called

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions