Difference between revisions of "X3D JSON Encoding"
From Web3D.org
(→Initial implementation: round-trip test) |
(sort sections) |
||
Line 1: | Line 1: | ||
These are X3D Working Group notes on the creation of an X3D JSON encoding and a corresponding conversion process. | These are X3D Working Group notes on the creation of an X3D JSON encoding and a corresponding conversion process. | ||
+ | |||
+ | == Initial implementation == | ||
+ | |||
+ | * Experimental [http://www.web3d.org/x3d/stylesheets/X3dToJson.xslt X3dToJson.xslt] stylesheet converts .x3d into .json encoding. In version control at [https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJson.xslt sourceforge] | ||
+ | * Embedded in [https://savage.nps.edu/X3D-Edit/ X3D-Edit] for testing | ||
+ | * Initial examples deployed ([http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorld.x3d .x3d]) ([http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorld.html .html]) ([http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorld.xhtml x3dom .xhtml]) ([http://x3dgraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorld.json .json]) | ||
+ | * Conversion syntax discussions continue on [http://web3d.org/pipermail/x3d-public_web3d.org/2014-October/002981.html x3dom-developers mail list] (with [http://www.x3dom.org/x3dom/test/functional/flipper.html round-trip test] by Dr. Yvonne Jung) | ||
== Conversion Considerations == | == Conversion Considerations == | ||
Line 40: | Line 47: | ||
Probably lots more... What else? | Probably lots more... What else? | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== References == | == References == |
Revision as of 18:37, 6 November 2014
These are X3D Working Group notes on the creation of an X3D JSON encoding and a corresponding conversion process.
Contents
Initial implementation
- Experimental X3dToJson.xslt stylesheet converts .x3d into .json encoding. In version control at sourceforge
- Embedded in X3D-Edit for testing
- Initial examples deployed (.x3d) (.html) (x3dom .xhtml) (.json)
- Conversion syntax discussions continue on x3dom-developers mail list (with round-trip test by Dr. Yvonne Jung)
Conversion Considerations
Primary design criterion: round-trippable lossless representation of X3D scene.
Conversion approach of greatest practical interest: XML to/from JSON. Issues:
- How to convert attribute names to distinguish them from child elements
- JSON handling of container elements to preserve parent/child relationships, distinguishing child elements from attributes
- Creation of JSON elements with datatypes appropriate to content (e.g., integer, float, strings, etc.)
- Both X3D and JSON can include comments, and so need an option for inclusion (by default) or removal (optional) of comments in order to ensure 100% round-trip conversion capabilities.
- Support for singleton (self-closing) XML tags also needs to be considered
- Inclusion and preservation of embedded XML namespace information in an XML (.x3d) document
Use cases
Are there any special use cases for having X3D JSON available in JavaScript?
- Are there any use cases that might modify how X3D is represented in JSON?
- If so, it would be good to spell them out and understand them well.
- We want conversion rules to permit implementations that can achieve user goals.
Standardization
Probably smartest to first start out defining an X3D best practice.
This capability likely needs to be defined as one of the X3D standards.
Discussion points
Here are suggested discussion points for X3D teleconferences and future followups.
- Is there a good/consistent way for X3DOM to utilize such capabilities?
- Is there a way for Three.js X3D loader, or other javascript libraries, to utilize such capabilities?
- Is there a single authoritative reference for JSON itself? and for JSON-XML conversions? See [6] for the JSON Data Interchange Format, need to confirm no others.
- What is the right file extension? .json, .x3dj or something else
- Can a file reader distinguish the incoming encodings (.x3d .x3dv .x3db .x3de .json) independent of file extension or MIME media type?
- Once a canonical form for X3D as JSON is established, add conversion capabilities to X3D-Edit and also autoconvert, test and publish JSON for all of the 3800+ scenes in the X3D Examples Archives
- Compare compression size and decompression speed of a TestMesh.x3d.json.gz to TestMesh.x3db and TestMesh.x3d.exi (EXI will likely win because it includes data typing)
Probably lots more... What else?
References
- XML to JSON Converter (provides option to assign a prefix to JSON attributes, default is @ character) http://www.freeformatter.com/xml-to-json-converter.html
- Apache Camel, XML JSON Data Format (camel-xmljson) [http://camel.apache.org/xmljson.html
- JavaScript Object Notation (JSON) Definition http://json.org
- ECMA 404: JSON Data Interchange Format (Final Draft) http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
- JSON Markup Language (JsonML) http://www.jsonml.org/
- XSLTJSON: Transforming XML to JSON using XSLT http://www.bramstein.com/projects/xsltjson
- Converting Between XML and JSON http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
- XML/JSON Perl Converter http://search.cpan.org/~ken/XML-XML2JSON-0.06/lib/XML/XML2JSON.pm
- IBM's PHP converter http://www.ibm.com/developerworks/library/x-xml2jsonphp
- Java Converter http://www.json.org/javadoc/org/json/XML.html
- Google Code Library https://code.google.com/p/x2js
Mailing list discussions