What is the best approach for serializing plots of Java objects?
My requirements for a serialization library 1) deserialization speed 2) size - as small as possible (less than Java default serialization) 3) flexibility - annotation-based descriptions that need to be serialized will be nice.
the main file format does not matter.
I looked at the protocol buffers and XStream, but the first one is not flexible enough due to the need to map files, and later creates large files.
Any help was appreciated.
For serialization, Hessian is one of the most effective.
2-3 , Java Serialization, Externalizable.
, , .
. , / ByteBuffer, Hessian ( 5 /, Java Serialization). , , . , ;)
Java, , .
, , . , , , , .
-, - , .. .
JSON Jackson : , XML ( PB, Hessian) ; , PB, JS ( ) .
, Java . , , transient? ( )
transient
http://jserial.sourceforge.net/ ?
Databoard .
.
@Referable class Node { public int id; public Node[] reference; public Node(int id, Node...reference) { this.id = id; this.reference = reference; } } public static void main(String[] args) throws Exception { Node a = new Node(0); Node b = new Node(1); Node c = new Node(2); a.reference = new Node[] {b, c}; b.reference = new Node[] {a}; c.reference = new Node[] {c}; Binding binding = Bindings.getBinding( Node.class ); Serializer s = binding.serializer(); byte[] data = s.serialize(a); Node d = (Node) s.deserialize( data ); System.out.println( binding.toString(d) ); }