Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abstract classes #9

Closed
JohnWeisz opened this issue Apr 27, 2016 · 3 comments
Closed

abstract classes #9

JohnWeisz opened this issue Apr 27, 2016 · 3 comments
Labels

Comments

@JohnWeisz
Copy link
Owner

JohnWeisz commented Apr 27, 2016

Overview

Remaining issues:

  • 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.

@JohnWeisz JohnWeisz added the bug label Apr 27, 2016
@JohnWeisz
Copy link
Owner Author

It can also happen that the deserializer actually instantiates an abstract class.

@JohnWeisz
Copy link
Owner Author

JohnWeisz commented Apr 29, 2016

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.

@JohnWeisz JohnWeisz modified the milestone: v0.1.3 Apr 30, 2016
@JohnWeisz
Copy link
Owner Author

root type part separated into issue #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant