======JSON XML Schema (JXML)====== A proposal for a simple XML schema which represents JSON data. =====Abstract===== In order to generate, read, and process JSON data using XML Tools it is useful to model the JSON Data Model using XML instead of using the JSON Text Serialization format directly. This proposal specifies an XML schema which directly models the JSON Data Model within XML. Simple tools can be used to translate to and from this schema to JSON Text Serialization, allowing XML tools to work with the JSON data model directly in XML. ====Goals==== The goals of this schema are to provide a simple XML representation of the JSON data model. By defining JSON in XML, and accompanying tools for parsing and serializing to/from JSON to XML(JXON), XML tools can be used without reguards to JSON serialization itself and instead focus purely on the data model transformations. The JXML schema is intended as a very simple schema which represents the entire JSON data model as directly as possible. It is not intended necessarily as the best schema to use to represent data in XML, but rather as a schema as close to the JSON data model as reasonable. Most likely use cases would involve transforming this to or from a more usable XML format for particular applications. Using this schema and a supporting implementation, JSON may be 'round tripped' losslessy through XML. ( JSON -> XML -> JSON) but not visa-versa. =====Use Cases===== - Store JSON data in an XML database. - Use of XML tools for JSON transformations. - Use of XML tools for JSON data validation. - Use of XML tools to generate JSON data without reguards to serialization issues. - Use of XML tools to consume JSON data without regards to JSON parsing issues. ======Schema====== The schema is based on the JSON data model as described at [[http://www.json.org]]. It consists of the following elements - object - member - boolean - array - string - number - null ===== Element object===== Attributes: none Child Elements: zero or more "member" elements Text: empty ===== Element member===== Attributes: name Child Elements: Exactly one 'value' (object|boolean|array|string|number|null) Text: empty ===== Element boolean===== Attributes: none Child Elements: none Text: "true" or "false" ===== Element array===== Attributes: none Child Elements: Zero or more 'value' (object|boolean|array|string|number|null) Text: none ===== Element string===== Attributes: none Child Elements: none Text: The value of the string Any charactors not allowed within XML must be JSON escaped. This includes the unicode range - 0x0000 - 0x0008 - 0x000B - 0x001F - 0XFFFE-0xFFFF All other characters should be represented natively in XML, and when text serialized entity encoded. ===== Element number===== Attributes: none Child Elements: none Text: the value of the number in XSD "double" format ===== Element null===== Attributes: none Child Elements: none Text: empty =====Diagram===== {{image url="http://xml.calldei.com/JsonXML/files.xml?action=download&file=jxml.jpg" title="JXML Diagram" alt="JXMLDiagram"}} ======Implementations====== The JXML schema is supported by [[http://www.xmlsh.org xmlsh]] by the commands [[http://www.xmlsh.org/CommandJson2xml json2xml]] and [[http://www.xmlsh.org/CommandXml2json xml2json]] ======Download====== The schema in XSD form (jxml.xsd) and diagram (jxml.jpg) may be downloaded here {{files}} ======Example====== JSON %%(json) { "foo": [true,null,1.23, { "bar":"spam" } ] } %% JXML %%(xml) true 1.23 spam %%