Open
Description
I am trying to deserialize my result
of a specific type MyType
. For some
const myJson= <MyType><any>resultJson; //resultJson comes through the server with a valid value
myVal = deserialize(MyTypeA, JSON.parse(myJson)); //myVal.a='a' myVal.b='b' and myVal.id=1
myType = new MyType(myVal.a, myVal.b);
MyTypeA
has the following structure:
`let i = 0;`
export class MyType{
readonly id: number;
@JsonProperty('a')
a: string;
@JsonProperty('b')
b: string;
constructor(a?: string, b?: string) {
this.a= a;
this.b= b;
this.id = i++;
}
}
However, when I try to instantiate my object my constructor is being called and thereafter the deserializer (via index.js
) overwrites my non-annotated readonly
attribute from 1
to undefined
. This is through the deserialize function
.
Any idea why this function overwrites my already-existing attribute?
Metadata
Metadata
Assignees
Labels
No labels