[x3d-public] X3DJSAIL JSON loader (yes!)

John Carlson yottzumm at gmail.com
Wed May 20 18:21:23 PDT 2020


https://www.web3d.org/specifications/java/X3DJSAIL.html

say .json import/file load is TODO.

Here is a sample Node.js file which shows the feature, and the Nashorn has
a similar example.

var java = require('java');
var autoclass = require ('./X3Dautoclass');
var X3DJSONLD = java.import("net.coderextreme.X3DJSONLD")
var loader = new X3DJSONLD();
var File = java.import("java.io.File")
var jsobj = loader.readJsonFileSync(new
File("./examples/HelloWorldProgramOutput.json"));
var document = loader.loadJsonIntoDocumentSync(jsobj);
console.log(loader.serializeDOMSync(loader.getX3DVersionSync(jsobj),
document));
var X3DLoaderDOM = java.import("org.web3d.x3d.jsail.X3DLoaderDOM")
var xmlLoader = new X3DLoaderDOM();
var X3D0 = xmlLoader.toX3dObjectTreeSync(document);
X3D0.toFileX3DSync("./examples/Json.x3d");
X3D0.toFileJSONSync("./examples/Json.json");


Note that this is easily converted to Java.  I've done it once, in fact.
All these pure Java functions (minus Sync) are available in Java code.

This leverages a port provided to X3DJSAIL which does the JSON -> DOM
conversion in the X3DJSONLD.java class.

Might I suggest that browser vendors leverage X3DJSAIL jars and openjdk to
support X3D JSON until a C/C++ version is complete?  Some lubrication ($$)
is currently required to get a C/C++ version pushed out the door (I can't
stand dealing with Xerces, CMake, autoconf), but last time I tried it, the
alpha version worked.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200520/909a21b7/attachment.html>


More information about the x3d-public mailing list