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
Abstract classes cannot be specified as JSON root type.
Fixed:
Abstract classes cannot be specified as property type
Abstract classes would sometimes actually be instantiated
Notes
Specifying an abstract class as the root type of a JSON object is a practical use scenario. Currently the type signature of TypedJSON.parse does not allow it:
parse<T>(text: string,type: {new(): T}): T;
Enabling abstract classes to be specified as type would be possible with the following overload signature (besides accepting any):
parse<T>(text: string,type: Function): T;
... which would however also effectively lift the requirement of parameterless constructors. As such, this issue will remain open until a suitable solution is found.
The text was updated successfully, but these errors were encountered:
Starting from v0.1.2, the refersAbstractType option can be specified for JsonMembers, which should be used when the property is an abstract type. This will instruct the deserializer to require a type-hint for the given property.
Also, JsonObject is now mandatory on classes containing JsonMember marked properties, and JsonObject cannot be used on an abstract class.
Abstract types still cannot be specified as the root type of the parsed JSON.
Overview
Remaining issues:
Fixed:
Notes
Specifying an abstract class as the root type of a JSON object is a practical use scenario. Currently the type signature of
TypedJSON.parse
does not allow it:Enabling abstract classes to be specified as
type
would be possible with the following overload signature (besides acceptingany
):... which would however also effectively lift the requirement of parameterless constructors. As such, this issue will remain open until a suitable solution is found.
The text was updated successfully, but these errors were encountered: