October 12th, 2008

amused, happy
  • mart

A Round-trippable Mapping Between JSON and XML

One thing I like about JSON is that it has types that map nicely on to types found in most everyday programming languages: strings, numbers, booleans, arrays, maps and null. XML, on the other hand, has basically two types: "element" and string. Element doesn't map particularly well onto any everyday programming language. Apparently, though, some frameworks make it easier to parse XML than JSON. (Go figure!) Certain protocols are requiring XML to be supported as a lossy transformation of JSON. I got to thinking that it would be useful to have an XML-based data format that can map to and from JSON without losing information.

Collapse )