Java Serialization to XML 
download > support > buy

uses
- features
- benefits
technology
accuracy

customers
case studies

pricing
about us

JSX 2.3.0.5 (Monday 26 May 2014)
This release corrects an error in the message given upon free trial expiry.


DOWNLOAD trial version of JSX jar (97557 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
   Mailing list archives

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 JSX2.3.0.5.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 JSX2.3.0.5.jar JSX.ObjectReader < test.xml
or, instead of redirecting standatd input, use an explicit filename:
   java -classpath JSX2.3.0.5.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.


Get started
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"));
   out.writeObject(yourObject);
   out.close();

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);

...to this:
   ObjectOutputStream out = new JSX.ObjectWriter(myout);

Do the same for any ObjectInputStream constructors, and that's it! There's nothing else to do!