yeah, these are general problems with data serialization, namely that
there is no good way to deal with "everything" within any reasonable
level of complexity.
it is easier then to find a reasonable subset of things that can be
serialized via a given mechanism, and use this.
At one point I did a lot of work with ASN.1, which is a specification
for defining protocols but is implemented using a variety of encoding
schemes. It actually is an effective means of serializing data and can
be very compact and, as I recall, extended to covering most data
encodings that I ran into but it never seemed trivial to me. Debugging a
stream of encoded data can lead to premature blindness and post
traumatic drunkenness. Well, maybe that was just me. To interpret the
data correctly you need the specification for encoding, BER for example,
and also the ASN.1 specification.
Lately I've been embedding the V8 engine in an application. I haven't
looked at how they've implemented the JSON objects but it might be worth
a peek for anyone interested in serialization techniques. I'm very