JSX 22.214.171.124 (Thursday 6 March 2014)
This release brings JSX closer to the JOS spec for class evolution, which is especially important when deserializing data to a new version of Java (since class internals evolve between Java releases).
trial version of JSX jar (96885 bytes)
Please email technical questions to the mailing list
JSX works with Java 1.2, 1.3, 1.4, 1.5, 1.6 and 1.7
Please post bug reports to the mailing list (please
include complete stack traces, XML and code so that the problem can be
reproduced) bug report
Docs for convenience methods are here: JSX.P
XML Schema for JSX: jsx.xsd
Command line test
Cut and paste this "export" test to the command line:
java -classpath JSX126.96.36.199.jar JSX.ObjectWriter > test.xml
Which generates XML something like this:
test.xml (or try this
test.xml.txt for some browsers)
"Import" by cutting and pasting this to the command line:
java -classpath JSX188.8.131.52.jar JSX.ObjectReader < test.xml
or, instead of redirecting standatd input, use an explicit filename:
java -classpath JSX184.108.40.206.jar JSX.ObjectReader test.xml
Edit "test.xml" by hand and import it again - thus, you can process object data
independently of the objects themselves.
Write out an object:
new JSX.ObjectWriter(new FileWriter("my.xml")).writeObject(yourObject);
Note: with older versions of JSX2, you need to explicitly close the stream (or you'll get an EOFException when reading):
JSX.ObjectWriter out = new JSX.ObjectWriter(new FileWriter("my.xml"));
Read it in again:
Object obj = new JSX.ObjectReader(new FileReader("my.xml")).readObject();
Note: in all these examples, you can omit the Writer and Reader argument to the
constructor, and JSX will default to System.out and System.in for convenience
when testing. They also accept OutputStreams and InputStreams.
Switch to JSX
To switch from Java's binary serialization to JSX, you only need to
replace its constructor with JSX. JSX is a drop-in replacement for
standard Java serialization, so nothing else needs to be changed
- only the constructor.
For example, change your code from this...
ObjectOutputStream out = new ObjectOutputStream(myout);
ObjectOutputStream out = new JSX.ObjectWriter(myout);
Do the same for any ObjectInputStream constructors, and that's it! There's
nothing else to do!