[X3D-Public] x3d to json experiments & links of interest

Don Brutzman brutzman at nps.edu
Mon Jul 7 16:46:59 PDT 2014


Still hoping to hear from x3dom developers on their use of JSON and relevant use cases of X3D in JSON form.

> 6.  Suggested discussion points for the X3D teleconference and future followups.
>
> a.  What are the use cases for having X3D JSON available in JavaScript?  It would be good to spell them out and understand them well.
> b.  Is there a good/consistent way for X3DOM to utilize such capabilities?
> c.  Is there a way for Three.js or other javascript libraries to utilize such capabilities?
> d.  Is there a single authoritative reference for JSON itself? and for JSON-XML conversions?
> e.  Compare compression of a TestMesh.x3d.json.gz to TestMesh.x3db and TestMesh.x3d.exi
>      (EXI will likely win because it includes data typing)
> f.  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 the3800+ X3D Examples Archive scenes
> g.  Decide if this capability needs to be defined in one of the X3D standards, or perhaps as an X3D best practice.
> h.  Probably lots more... What else?

More information on JSON <==> XML follows.

=====================================================================

Don McGregor (who has translated the DIS protocol to JSON) reports the following ECMA standard for JSON.

http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf  (14 pages)

It does not mention XML, and therefore does not address the potential use of - or @ (or whatever) characters to distinguish child JSON fields as elements or attributes. Absent any other specifications, this would seem to provide rationale for our defining an official JSON encoding for X3D.

The following commercial posting discusses this issue a little:
	XSLT and XPath for JSON
	By Mark Joseph - May 6, 2008
	https://www.p6r.com/articles/2008/05/06/xslt-and-xpath-for-json

=====================================================================

The following reference from json.org is also interesting:

	JsonML.org
	JSON Markup Language (JsonML)

> JsonML (JSON Markup Language) is an application of the JSON (JavaScript Object Notation) format. The purpose of JsonML is to provide a compact format for transporting XML-based markup as JSON which allows it to be losslessly converted back to its original form.
>
> Native XML/XHTML doesn't sit well embedded in JavaScript. When XHTML is stored in script it must be properly encoded as an opaque string. JsonML allows easy manipulation of the markup in script before completely rehydrating back to the original form.

This site also includes the following syntax definition for lossless round-trip conversion:

	http://www.jsonml.org/syntax

> Syntax Reasoning
>
> JsonML was designed for lossless roundtrip conversion between XML and JSON and to handle "mixed-mode content" (i.e., textual data outside of or next to elements). Key considerations were lossless two-way conversion and compactness of form. JsonML handles namespaces in the same way that XML 1.0 does: attributes for xmlns and tag names with colons.
>
> JsonML was never intended to be the way that everything that could be expressed in XML should be expressed in JSON. JsonML is the only transformation which can safely encode "mixed-mode" content in XML, which is a key characteristic in a markup language such as XHTML. Many other transformations exist for representing XML in a JSON format.
>
> Grammar (BNF)
>
> The following grammar represents how XML-based markup (e.g. XHTML) is encoded into JsonML. As per JSON, whitespace is permitted between tokens.
> [...]

=====================================================================

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the X3D-Public mailing list