What is WOX?
WOX is an XML serializer for Java and C# objects. In other words, WOX is a library (woxSerializer.jar for Java, and woxSerializer.dll for C#) to serialize Java and C# objects to XML and back again. One of its main features is the generation of standard XML, which is language independant. This means that if we serialize a Java object to XML, we could take the generated XML to reconstruct the object back to C#; and viceversa.
WOX provides a simple and robust way of serializing objects to XML. It is easy to use, and you do not have to modify your source files with any special declarations. The source code is provided, and you are free to adapt it for your own purposes.
Some of the WOX main features are listed below.
- Easy to use. The Easy class provides serialization and de-serialization methods.
- Simple XML. The XML generated is simple, easy to understand, and language independent.
- Requires no class modifications. Classes do not require to have default constructors, getters or setters.
- Field visibility. Private fields are serialized just as any other field. WOX serializes fields regardless their visibility.
- Interoperability Java and C#. WOX can serialize a Java object to XML, and reconstruct the XML back to a C# object; and viceversa.
- Standard XML object representation. This could potentially allow to have WOX serializers in different object-oriented programming languages.
- WOX data types. The WOX mapping table specifies how primitive data types are mapped to WOX data types.
- Robust to class changes. Defaults will be used for newly added fields.
- Arrays. Handles arrays and multi-dimensional arrays of primitives and Objects.
- Base-64. Byte arrays are base-64 encoded for efficiency.
- Collection classes. Lists and Maps are provided as WOX data types. (ArrayList and HashMap in Java; ArrayList and Hashtable in C#).
- Object references. Handles duplicate and circular object references with id/idref.
- Class and Type. Objects of these classes are saved by their String name.
- Small footprint. The woxSerializer.jar file (which contains only .class files) is only 25k.
You can use WOX if you need to:
- Transport an object. Serializing the object allows you send it through a network. Then it can be reconstructed at the other end.
- Store an object. Persisting objects with WOX is easy. You can use them later.
- Represent an object in a standard format. The XML generated by WOX aims to be independent of the language in which the object was created.
- Work with Java and C# objects. Java and C# objects can be serialized/de-seralized to/from XML.
- Tests. You could serialize an object to inspect all its fields-objects.
- Duplicate an object. Serialization is an easy way to duplicate objects.
This WOX serializer is highly used in our WOX framework, which is an object-based distributed system. The WOX serializer is used to serialize the objects that are sent through the network, as well as the messages (objects) that are exchanged between WOX clients and servers. Our WOX framework is also available as an open-source project.
Some of the known limitations only apply to WOX in C#. See below. If you find any other limitations, please let us know.
- Some problems have been noticed when serializing classes that declare synchronize methods.
- Final fields can be serialized, but their de-serialization is not satisfactory.
- WOX in Java does not require classes to define default constructors to be de-serialized from XML, but WOX in C# does.
- Base-64 is fully implemented in WOX in Java, but not in WOX in C#.