Open nicolaedaian opened 5 years ago
I don't think json2typescript will properly work with get/set methods for properties, you should always use it with the field.
I don't know if it would be easy to implement this, but I don't think so. If you know, you are welcome to give some input!
Yeah, I ended up doing the following:
private toJSON = () =>
{
return {
width: this.width,
height: this.height
}
}
You could also use custom converters and call the set/get methods there. But the decorator needs to be set to the field.
Custom converters are a good way to assign anything you want, not just simple strings. We could actually implement a solution where json2typescript automatically calls the get/set methods, if there are some. I will keep this open for future reference.
Please look at the below code. I expect the result of the serialization to be
Instead it is
How can I make json2typescript to use the name of the properties in the Coord and Size classes instead of using the name of the properties in the (common) base class Pair?