-
Notifications
You must be signed in to change notification settings - Fork 5
Relax requirements for vibe.data.json using toJson? #17
Description
Currently, vibe.data.json will only call toJson if both toJson and fromJson is defined.
However, not all applications require both serialization and deserialization.
I'm also wondering if it would make sense to simply check if something called toJson exists on the object. The reason is that the current method, which performs speculative compilation, hides any errors in the implementation of toJson and fromJson - if the method exists, but the speculative call fails for any reason, then it is treated as if it's absent, which usually leads to incorrect serialization instead of an explicit error. This is especially relevant when these methods are templated, which can be useful when we have many types, out of which only some will actually need to be serialized, to reduce the total amount of compiled code.