I have some Java code that is using flexjson.JSONDeserializer and flexjson.JSONSerializer. (simply speaking JSONDeserializer creates an class instance using property value pairs from a String of JSON and JSONSerializer takes a class instance and creates a String of JSON.)
And now I have a need to also use something similar for XML, what is the best match and is there something similar but that has better performance?
simple example
class X {
private Integer a;
public void setA(Integer a);
public Integer getA();
}
with json equal to {"a":1} I have the following
new JSONDeserializer<X>().use(null, X.class).deserialize(json);
with json equal to [{"a":1},{"a":2}]
new JSONDeserializer<List<X>>().use(null, ArrayList.class).use("values", X.class).deserialize(json);
Edit
Comparision of XStream and JAXB here
I still need to compare them again.
End Edit
XStream seems easier than the JAXB option since I am also dealing with collections of X
code of serialization is simply
Maven dependences are
and in your java file add