You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be very useful for some use cases to support serialisation / deserialisation of heterogeneous arrays (via type inheritance). For example:
@json
abstract class Animal {
name!: string;
type!: string;
// add a decorator to mark this as the type discrimator
// or allow a callback in options to pass a method to return the type at runtime?
}
@json
class Dog extends Animal {
age!: i32;
}
@json
class Cat extends Animal {
isVerified!: boolean;
}
@json
class Zoo {
animals!: Animal[]
}
export function parse(stringified: string) : string {
const zoo = JSON.parse<Zoo>(stringified, true);
const out = JSON.stringify<Zoo>(zoo);
return out;
}
It would be very useful for some use cases to support serialisation / deserialisation of heterogeneous arrays (via type inheritance). For example:
And:
The text was updated successfully, but these errors were encountered: