A JSON encoding for X3D Roy Walmsley roy.walmsley@ntlworld.com Don - - PowerPoint PPT Presentation

a json encoding for x3d
SMART_READER_LITE
LIVE PREVIEW

A JSON encoding for X3D Roy Walmsley roy.walmsley@ntlworld.com Don - - PowerPoint PPT Presentation

Consortium A JSON encoding for X3D Roy Walmsley roy.walmsley@ntlworld.com Don Brutzman brutzman@nps.edu John Carlson john@carlsonsolutiondesign.com Web3D 2016, Anaheim, California 23 rd July 2016 1 Consortium Contents ISO/IEC standards


slide-1
SLIDE 1

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

A JSON encoding for X3D

Roy Walmsley

roy.walmsley@ntlworld.com

Don Brutzman

brutzman@nps.edu

John Carlson

john@carlsonsolutiondesign.com 1

slide-2
SLIDE 2

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Contents

  • ISO/IEC standards
  • Requirements
  • JSON structure
  • Methodology
  • Encoding of nodes
  • Encoding of fields
  • Validation
  • Implementations

2

slide-3
SLIDE 3

Web3D 2016, Anaheim, California 23rd July 2016

Consortium Series Title Part Content 19775 X3D 1 Architecture 2 Scene access interface (SAI) 19776 File encodings 1 XML (.x3d) 2 Classic VRML (.x3dv) 3 Compressed Binary (.x3db) 19777 Language bindings 1 ECMAScript 2 Java Series Title Part Content 19775 X3D 1 Architecture 2 Scene access interface (SAI) 19776 File encodings 1 XML (.x3d) 2 Classic VRML (.x3dv) 3 Compressed Binary (.x3db) 5 JSON (.x3dj or .json) 19777 Language bindings 1 ECMAScript 2 Java

ISO/IEC standards

3

slide-4
SLIDE 4

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Requirements

  • Must fully specify everything defined in the

X3D abstract specification.

– Nodes and fields – Statements and other constructs – Comments – Scripts and Shader code

  • "Round trippable" with no loss of X3D content

for any of the file encodings.

4

slide-5
SLIDE 5

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

JSON structure

  • Two primary data structures

– Objects: An unordered collection of name/value pairs – Arrays: An ordered collection of values

  • JSON value

– Object, array, number, string, true, false, null

  • Structural tokens

– { } [ ] : , – Strings delimited by "

  • JSON doesn't have specific comments structures

5

slide-6
SLIDE 6

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Methodology

  • Examples archive – stylesheet conversion
  • JSON validation
  • Specific issues:

– Handling of ROUTEs and Comments – Character escaping – No hexadecimal number representation

  • X3D JSON Validation
  • Implementation

6

slide-7
SLIDE 7

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Encoding of nodes

  • Nodes encoded:

– In XML as elements, e.g. <Group/> – In JSON as objects, e.g. "Group":{}

  • Node type is name in name/value pair
  • Empty object means all attributes have default values

7

slide-8
SLIDE 8

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Encoding of fields

  • Usefully categorized as follows:

– 'value field', holds numbers, strings, or boolean true/false – 'node field', holds references to other nodes

  • Field names are strings, so to distinguish them

from other strings a name is prepended with:

– '@' for value fields – '-' for node fields

8

slide-9
SLIDE 9

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Encoding of value fields

  • In XML fields are attributes of elements

(nodes), e.g.:

<Group bboxSize='-1 -1 -1'/>

  • In JSON fields are properties of objects

(nodes), e.g.:

"Group": { "@bboxSize":[-1,-1,-1] }

9

slide-10
SLIDE 10

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Encoding on node fields

  • In XML referenced nodes are child elements, e.g.

<Group bboxSize='-1 -1 -1'> <Viewpoint containerField='children'/> <Group/>

  • In JSON the field is a property of the containing

node, and the referenced node is an object, e.g.

"Group": { "@bboxSize":[-1,-1,-1], "-children": [ { "Viewpoint": {} } ] 10

slide-11
SLIDE 11

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Comments / ROUTEs, etc.

  • In XML: <!–- This is a comment -->
  • In JSON: "#comment":"This is a comment"

<Group bboxSize='-1 -1 -1'> <!–- Before Viewpoint --> <Viewpoint containerField='children'/> <!-- After Viewpoint --> <Group/>

"Group":{ "@bboxSIze":[-1,-1,-1], "#comment":"Before Viewpoint", "-children":[ {"Viewpoint":{}} ], "#comment":"After Viewpoint" } "Group":{ "@bboxSIze":[-1,-1,-1], "-children":[ {"#comment":"Before Viewpoint"}, {"Viewpoint":{}}, {"#comment":"After Viewpoint"} ] }

11

slide-12
SLIDE 12

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Validation

  • Like XML, use a Schema

– Covers all X3D nodes, statements, etc. – Available online at:

http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json

  • JSON schema has improved validation capabilities:

– Validates child node content of individual node fields – Validates individual array elements

12

slide-13
SLIDE 13

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Implementations

  • For web browsers:

– X3DOM and Cobweb use XML encoded files – JSON loader developed. Either:

  • Loads directly into DOM, or
  • Via XML to X3DOM or Cobweb
  • A standalone C++ application

– Uses XML encoded files – JSON loader / validator developed

13

slide-14
SLIDE 14

Web3D 2016, Anaheim, California 23rd July 2016

Consortium

Questions

14