JohnWeisz/TypedJSON

onDeserialized -> beforeSerialization

valentinstn opened this issue · 3 comments

I'm already using the onDeserialized option to call specific object methods after the deserialization of the JSON strings. I'd also have the requirement to run one method (e.g. beforeSerialization) before each serialization of the typed objects i.e. run custom code in the other direction.

It is not a big thin, as I'm currently running that code inside of an Angular service, but it would be cleaner to define that logic inside the model to also be consistent with the onDeserialized logics.

I could set-up a pull request for that, is there anything speaking against such a functionality or is there maybe an alternative way to achieve that goal? The method's serializer options are not good for that, as the behaviour depends on the combination of two properties.

Hey M55c55, nothing against it, quite the contrary I think it would be cool. It would improve the symmetry between deserialization and serialization. If you need any guidance navigating the code just let me know.

Hey M55c55, your PR is included with now released 1.5.0, thanks for the submission.

Hi @Neos3452 , thank you for the merge and the new release! 👍