It's the type data that makes this hard: JSON has no support for encoding new types into the serialization. This is a blessing and a curse: it makes JSON simple, but also inflexible.<p>Take this parting remark:<p>> So, here’s another thing I wanna add to my suggestion: consider adapting ISO 8601 for a default JSON serialization of DateTime, so the following just works:<p>> var dt = DateTime.parse("2014-01-26T11:38:17");<p>> print(JSON.encode(dt));<p>Ignoring the fact that it's a simple value you're attempting to encode to JSON, let's say this works. Do you get:<p><pre><code> "2014-01-26T11:38:17"
</code></pre>
Now do to the reverse: what does that decode to? Either it decodes to a string, and you've lost the type information, or it decodes to a date, in which case, what does `JSON.encode("2014-01-26T11:38:17")` decode to? i.e., do strings sometimes decode to dates? What if someone uses what should be a string to cause the decoder to decode it as a date? Now anywhere you have a string, it might decode to a date!<p>YAML has support for this sort of thing, with a syntax like `!!date "2014-01-26T11:38:17"`. (If you want a literal `!!`, it's always `"!!"`.) Notably, the Python library for YAML <i>can</i> do what the author asks: encode and decode arbitrary objects. (but it turns out to be a security risk to do so on untrusted data.)<p>> The Dart editor should be able to display a JSON serialization of anything the mouse pointer touches.<p>If my class contains a file handle, what's the JSON representation of a file handle? Further, if I send that serialization across the wire, how do you deserialize it? I mention this because you can't, at least, not really. Python's `repr` is a good example here. When it can, it gives you close-to Python syntax for the object, such as strings (`"hello world"`), ints (`1`), decimals (`Decimal(3)`), etc. Perfect for debugging. For things it can't, you get something like `<file object "~/foo.txt" at 0xdeadbeef>` — which doesn't parse (on purpose) as Python.<p>I'd venture to say that what you really want is the ability to introspect. Take your customer example: if you could introspect it, and see what member variables were present, you could build a function that might output:<p><pre><code> {"type": "Customer", {"Id": 1, "Name": "Joe Bob"}}
</code></pre>
Again, note the explicit serialization of the type here, in JSON. This is something <i>I</i> made up, of course, and not JSON. Of course, some language feature can make introspection interesting. (Can you even get a list of members? Some languages allow objects to make up members on-the-fly.)<p>Hopefully, I've convinced you language design is hard. :-)