Closed quldude closed 1 year ago
Hi, I tried your code and it works.
Are you sure you have deserialize your object?
import { JsonObject, JsonProperty, JsonSerializer } from "typescript-json-serializer";
class WrappedArray {
id: number
}
@JsonObject()
export class TestResolutionStates {
@JsonProperty('__wrappedArray')
public wrappedArray: WrappedArray[];
}
const json = {
"__wrappedArray": [{id: 1}, {id: 4}]
}
const jsonSerializer = new JsonSerializer();
const resolutionStates: TestResolutionStates = jsonSerializer.deserializeObject(json, TestResolutionStates);
const result = resolutionStates.wrappedArray.find((a => a.id === 4))
console.log(result) // {id: 4}
I'm getting a different error now. See here. Do you know of a way to resolve it?
It seems Babel does not support decorator correclty
Version
5.1.0
Description
Not able to read property that has a decorator with json property name.
Error
Reproduction
Enabled these in tsconfig:
I have a class defined as such:
When I call
this.resolutionStates.wrappedArray.find(...)
, I get an error. The json string is defined as:On which OS the bug appears?
windows
What is your project type?
nodejs
On which build mode the bug appears?
No response
Anything else?
No response