[x3d-public] X3DJSAIL documentation: Using X3DJSONLD.java (from sourceforge) to load JSON into DOM and write out as XML

John Carlson yottzumm at gmail.com
Mon Apr 16 18:26:01 PDT 2018


/*
  * Iniitalize Loader
  */
X3DJSONLD loader = new X3DJSONLD();
/*
  * Read a JSON file Nashorn.json into a JsonObject
  */
javax.json.JsonObject jsobj = loader.readJsonFile(new java.io.File("Nashorn.json"));
/*
  *Convert JsonObject to XML DOM Document
  */
Document document = loader.loadJsonIntoDocument(jsobj);
/*
  * Initialize X3DJSAIL DOM Loader
  */
org.web3d.x3d.jsail.X3DLoaderObject xmlLoader = new X3DLoaderObject();
/*
  * Load DOM  into X3DObject
  */
X3DObject X3D0 = (X3DObject)xmlLoader.toX3dObjectTree(document);
/*
  *  Do X3D-like things  with X3D0, validate etc.
  */
/*
 * Write out X3DObject as XML file Nashorh.x3d
  */
X3D0.toFileX3D("Nashorn.x3d");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180416/6aee50f4/attachment-0001.html>


More information about the x3d-public mailing list