Skip to content
New issue

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

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

Already on GitHub? # to your account

serializer.pre_serialize event only thrown on objects/classes #337

Closed
ReservedDeveloper opened this issue Sep 16, 2014 · 4 comments
Closed

Comments

@ReservedDeveloper
Copy link

The events system is a great piece of functionality for being able to dynamically modify the serialization process. Unfortunately, as currently implemented, there is no way to make modifications to primitives prior to their serialization.

At a very casual glance, it could be as simple as moving the responsible block (starts // Trigger pre-serialization callbacks, and listeners if they exist.) to a higher line, allowing us to hook in for all types.

Would their be any hindrances/complications in doing so? (assuming all RuntimeExceptions have been checked)

@luxifer
Copy link

luxifer commented Dec 17, 2014

I'm having te same problem...

@luxifer
Copy link

luxifer commented Dec 17, 2014

Same problem for serializer.post_serialize events...

@TiS
Copy link

TiS commented Oct 13, 2015

+1. I want to be able to sometimes change the type of to-be-serialized value.

For example: my application uses big integers as entity IDs. The problem is, the Javascript does not handle such big integers well. I want to be able to detect, if the integer is bigger than some value and then change the serialized type to string (so it is enclosed in quotes). Currently I have to create an object with the integer value and register a handler for it. But this is not possible, the code bas is just too big, and making such a change in a model just because of serialization problems is overkill.

@goetas
Copy link
Collaborator

goetas commented Aug 3, 2016

As of 1.2.0 is possible to register handlers on primitives. See #222 (comment) to see how to create handlers for primitives

@goetas goetas closed this as completed Aug 3, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants