[x3d-public] Aha! X3DJSAIL validates X3DJSON.

John Carlson yottzumm at gmail.com
Sat Apr 25 09:56:06 PDT 2020


I've been worrying a bit about JSON validation against a non-existent
schema standard, and I finally realized that at X3DJSAIL (the Nashorn
version at list) can validate JSON!

Here is example Nashorn code which can lead in that direction!  Now that we
have a validator (essentially), can we move towards standardization of X3D
JSON?

I can work on a Node.js version if necessary!

Thanks,

John

load('classpath:nashorn/node/X3Dautoclass.js');
var ConfigurationProperties =
Packages.org.web3d.x3d.jsail.ConfigurationProperties;
ConfigurationProperties.showDefaultAttributes = false;
ConfigurationProperties.xsltEngine =
ConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA;
ConfigurationProperties.deleteIntermediateFiles = false;
ConfigurationProperties.setStripTrailingZeroes(true);

    var X3DJSONLD = Java.type("net.coderextreme.X3DJSONLD")
    var loader = new X3DJSONLD();
    var File = Java.type("java.io.File")
    var jsobj = loader.readJsonFile(new
File("./examples/HelloWorldProgramOutput.json"));
    var document = loader.loadJsonIntoDocument(jsobj);
    print(loader.serializeDOM(loader.getX3DVersion(jsobj), document));
    var X3DLoaderDOM = Java.type("org.web3d.x3d.jsail.X3DLoaderDOM")
    var xmlLoader = new X3DLoaderDOM();
    var X3D0 = xmlLoader.toX3dObjectTree(document);
    X3D0.toFileX3D("./examples/Json.x3d");
    X3D0.toFileJSON("./examples/Json.json");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200425/dd177b26/attachment.html>


More information about the x3d-public mailing list