[x3d-public] JSON Encoding - Taking Don's idea one step further
Roy Walmsley
roy.walmsley at ntlworld.com
Mon Dec 21 11:53:30 PST 2015
Apologies. I looked through the listing and saw I had made some mistakes
with respect to commas and indentation. Here's a modified retry.
{ "Shape":
{
"-content":[
{ "#comment":"Sphere begin"},
{ "Sphere":
{
}
},
{ "#comment":"Sphere complete, Appearance begin"},
{ "Appearance":
{
"-content":[
{ "#comment":"Material begin"},
{ "Material":
{
"@DEF":"MaterialLightBlue",
"@diffuseColor":[0.1,0.5,1]
}
},
{ "#comment":"Material complete, ImageTexture begin"},
{ "ImageTexture":
{
"@DEF":"ImageCloudlessEarth",
"@url":["earth-topo.png"]
}
},
{ "#comment":"ImageTexture complete"}
]
}
},
{ "#comment":"Appearance complete"}
]
}
}
Roy
From: x3d-public [mailto:x3d-public-bounces at web3d.org] On Behalf Of Roy
Walmsley
Sent: 21 December 2015 19:46
To: Don Brutzman; John Carlson
Cc: x3d-public at web3d.org
Subject: [x3d-public] JSON Encoding - Taking Don's idea one step further
Don and John,
I can see the benefit of Don's idea. So, I have been trying to give it some
thought, and would like to make the following very radical, iffy,
suggestion:
Don's idea was to introduce a "-children" to accommodate ROUTES and
comments.
The current (or alternative) JSON encoding tends to treat it like a Classic
VRML encoding, in the sense of specifying the xFNode field names and then
adding the children.
My thought is, can we, say, add a "-content" field, and then add the content
more in the XML encoding style. So comments and ROUTEs become content, just
like child nodes. All nodes that have any children have a "-content".
Take a snippet from the HelloWorld example. This is Don's latest
incarnation:
{ "Shape":
{
"-children":[
{ "#comment":"Sphere begin"},
{ "#comment":"Sphere complete, Appearance begin"},
{ "#comment":"Appearance complete"}
],
"-geometry":[
{ "Sphere":
{
}
}
],
"-appearance":[
{ "Appearance":
{
"-children":[
{ "#comment":"Material begin"},
{ "#comment":"Material complete, ImageTexture begin"},
{ "#comment":"ImageTexture complete"}
],
"-material":[
{ "Material":
{
"@DEF":"MaterialLightBlue",
"@diffuseColor":[0.1,0.5,1]
}
}
],
"-texture":[
{ "ImageTexture":
{
"@DEF":"ImageCloudlessEarth",
"@url":["earth-topo.png"]
}
}
]
}
}
]
}
}
And this is what my idea would produce:
{ "Shape":
{
"-content":[
{ "#comment":"Sphere begin"},
{ "Sphere":
{
}
}
{ "#comment":"Sphere complete, Appearance begin"},
{ "Appearance":
{
"-content":[
{ "#comment":"Material begin"},
{ "Material":
{
"@DEF":"MaterialLightBlue",
"@diffuseColor":[0.1,0.5,1]
}
}
{ "#comment":"Material complete, ImageTexture begin"},
{ "ImageTexture":
{
"@DEF":"ImageCloudlessEarth",
"@url":["earth-topo.png"]
}
}
{ "#comment":"ImageTexture complete"}
]
}
}
{ "#comment":"Appearance complete"}
]
}
}
I don't know if it is valid JSON, but I hope it gives you the idea.
@containerFields would be added if required.
Pros and cons:
PRO: All comments remain in exactly the right places (so would also apply to
ROUTEs)
PRO: Uses the term "-content" which is not a term used elsewhere
CON: Would mean a complete rethink/rewrite of development tools.
Anyway, just an idea .
Regards,
Roy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20151221/f951fea6/attachment-0001.html>
More information about the x3d-public
mailing list