Tuesday, August 25, 2015

JsonML


"JsonML, the JSON Markup Language is a lightweight markup language used to map between XML(Extensible Markup Language) and JSON (JavaScript Object Notation). It converts an XML document or fragment into a JSON data structure for ease of use within JavaScript environments such as a web browser, allowing manipulation of XML data without the overhead of an XML parser."

JSON:

{"person": {
    "address": {
        "city": "Anytown",
        "postalCode": "98765-4321",
        "state": "CA",
        "street": "12345 Sixth Ave",
        "type": "home"
    },
    "created": "2006-11-11T19:23",
    "firstName": "Robert",
    "lastName": "Smith",
    "modified": "2006-12-31T23:59"
}}



JsonML (Array JSON), to preserve XML's elements order:

["person",
  {"created":"2006-11-11T19:23",
   "modified":"2006-12-31T23:59"},
  ["firstName", "Robert"],
  ["lastName", "Smith"],
  ["address", {"type":"home"},
    ["street", "12345 Sixth Ave"],
    ["city", "Anytown"],
    ["state", "CA"],
    ["postalCode", "98765-4321"]
  ]
]

<!-- XML representation of a person record -->
<person created="2006-11-11T19:23" modified="2006-12-31T23:59">
<firstName>Robert</firstName>
<lastName>Smith</lastName>
<address type="home">
<street>12345 Sixth Ave</street>
<city>Anytown</city>
<state>CA</state>
<postalCode>98765-4321</postalCode>
</address>
</person>



No comments: