-
-
Notifications
You must be signed in to change notification settings - Fork 587
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
Comments
I'm having te same problem... |
Same problem for |
+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. |
As of 1.2.0 is possible to register handlers on primitives. See #222 (comment) to see how to create handlers for primitives |
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)
The text was updated successfully, but these errors were encountered: