Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

X3D JSON loader and node.js express web server for serving files from localhost

Version 5.0.2

  • for using the API, read doc/GettingStarted.pdf There are still symbols in the global scope I'd like to get rid of. If you'd like to help, fork and issue a pull request.

  • Download and install git

git clone
  • If you want to use node.js as your web server, download and install node.js (npm comes with it). You can download examples from here:

  • Edit src/main/node/config.js for node.js, put maven in your path, install X3DJSAIL in your maven repository per the pom.xml (it's different than the X3DJSAIL distribution) and start a web server

npm install
node app.js

Then go to http://localhost:3000/index.html in your web browser and select a JSON file in the pulldown. You can try: http://localhost:3000/X3DExamplesViewer.html


You should not put up index.html from the X3D JSON Loader found here and here without careful consideration of this:

In particular, I am choosing tags, attribute names, and attributes right out of the JSON and XML with limited filtering or checking (just checking JSON schema, which may be ignored). You should validate any JSON or XML being loaded into the X3D JSON Loader (yes I know it’s problematic). In particular, if you store XML or JSON from untrusted sources and display them in the Loader, it’s likely you will get an XSS attack. Please sanitize all input from untrusted source and make sure it’s valid. We don’t currently have XML Schema or XML Schematron for JSON data yet. We do have JSON schema, but it doesn't test scripts.

It’s in the license that I will not be liable for damages. Please use my software with care. I am not a security researcher.

If someone wants me to write a sanitizer for the X3D JSON Loader, I am willing to for $$$. I will need to run it by some security researchers.

  • Converting JSON files to X3D XML, Python, Java and Nashorn JavaScript

The script, provides the driving software for producing XML, Python and Java, JavaScript artifacts from JSON. simply modify and run the script to suit. You can change the Java Serializer or any other serializer in json2all.js. There is a list of serializers there with corresponding file extensions.

  • Compiling and running Java, producing diffs of JSON input and output. The Java serializer produces a program which produces JSON. You can run the output from the serializer through the Java compiler and JVM with This will compile the java, run it, and provide a diff with the original JSON (if any). There are a couple of output zips for collecting output results.

  • also you can run "sh" or converting, running and diffing local files found in src/main/data.

  • Summary of shell scripts

These have been tested recently: -- run several .x3d files through my conversion and compiling and running code.  Recommend that you put the files in src/main/data and use sh ../data/file1.x3d ../data/file2.x3d ... -- run all .x3d in /c/x3d-code/ through my conversion and compiling and running code found in several.  Dangerous.  Puts files in strange places right now.  -- run src/main/data/*.x3d through -- run several .x3d files through don's conversion and compiling and running code. -- run src/main/data/*.x3d through

You will need to set up your classpath accordingly. You can modify the file in src/main/shell/classpath to set your classpath. You will probably have to build the project with Maven 3. This is accomplished by running putting maven's bin folder in your path and running mvn install in the root folder, which will build any Java code found in src/main/java. I use net/coderextreme/ to process stylesheets. Also, the website uses as well, so it would be good if you compiled it. You may need to configure the classpath in src/main/node/allsaxon.js as well.

The following are legacy code, and may be updated. -- used to post process jsonerrors.txt -- finish compiling code -- compile java in local folder and create zips -- finish converting code -- copy arguments to current folder.  Used with xargs. -- list non-compiled files which are encoding cp1252 -- compare outputs to inputs -- compare *.json to *.new.json -- compare *.x3d to *.new.x3d -- run all .x3d in /c/x3d-code/ through don's conversion and compiling and running code. -- finish executing code -- finish conversion and compiling of files in /c/x3d-code/ -- a script to run nashorn javascript *.js files -- report non-compiled code -- report non-converted code -- report non-executed java code -- report non-executed javascript -- report non-serialized x3d -- process JSON errors generated by -- a small shell script to test quoting and escaping -- replace NeedClassHere with name of class from filename.  Needed for Don's code -- do conversion and list python files -- run prototype expander and xml prototype expander -- run schema check for various things. -- create *.runerr.txt and *.runout.txt -- convert JSON to various formats. Produces jsonerrors.txt -- sum lines on standard input -- report on UNKNOWN routes from *.runerr.txt and *.runout.txt -- convert files from x3d to python