3 ms·
> Justin Fagnani's response hits it head on. It makes no sense to deserialize schema-less JSON into objects. What you should typically do in static languages w
by nly 12y ago
> Justin Fagnani's response hits it head on. It makes no sense to deserialize schema-less JSON into objects.
What you should typically do in static languages without reflection (C++ etc) is specify a mapping between the implicit JSON schema and your existing class definitions using a set of traits. Boost.Fusion for C++, for example, is one way to map an object to an arbitrary sequence you can utilise for serialization.
Code generation approaches, like out of the box generation from 'Protocol Buffers', is ugly and limited anyway, since you're then forced wrap or abstract away the generated code, or put up with its style and limitations. If your JSON schema changes in the future, for example, you will have to change your code all over the place rather than just the serialize/deserialize routines.