#phpc on Freenode had a discussion tonight about how there’s nothing in XML that’s quite as simple as JSON for encoding types. I came up with this off-the-cuff – as opposed to WDDX, this is more JSON-like in that each ‘XML Document’ encodes only a single value – but that value might be mapped to any of the built-in types.
Of course, the <object> stuff would only work with pretty simple objects – but the fact that it tries at all to instance a class is a step beyond what JSON does, which is ALWAYS an instance of stdClass. You could drop this extra ‘feature’ by remove removing line 43 ($class = …) and changing line 44 to:
[highlight lang=php]$data = new stdClass;[/highlight]