[x3d-public] X3DJSAIL JSON loading test case (java)

John Carlson yottzumm at gmail.com
Fri Jun 25 10:35:15 PDT 2021


package org.web3d.x3d.tests;

import net.coderextreme.X3DJSONLD;
import org.web3d.x3d.jsail.ConfigurationProperties;
import org.w3c.dom.*;
import javax.json.*;
import java.io.*;

import org.web3d.x3d.jsail.X3DLoaderDOM;
import org.web3d.x3d.jsail.Core.X3D;


public class JsonLoaderTest {
public static void main(String args[]) {
try {
ConfigurationProperties cp = new ConfigurationProperties();
cp.setXsltEngine(ConfigurationProperties.XSLT_ENGINE_NATIVE_JAVA);
cp.setDeleteIntermediateFiles(false);
cp.setStripTrailingZeroes(true);
X3DJSONLD loader = new X3DJSONLD();

JsonObject jsobj = loader.readJsonFile(new
File("examples/HelloWorldProgramOutput.json"));
Document document = loader.loadJsonIntoDocument(jsobj);
FileWriter fw = new FileWriter("examples/LoadedJsonConversion.xml");
fw.write(loader.serializeDOM(loader.getX3DVersion(jsobj), document));
fw.close();
X3DLoaderDOM  xmlLoader = new X3DLoaderDOM();
X3D X3D0 = (X3D)xmlLoader.toX3dModelInstance(document);
X3D0.toFileX3D("examples/JsonLoaderTest.x3d");
X3D0.toFileJSON("examples/JsonLoaderTest.json");
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210625/0fe315e9/attachment-0001.html>


More information about the x3d-public mailing list