我有一些使用 flexjson.JSONDeserializer 和 flexjson.JSONSerializer 的 Java 代码。(简单地说,JSONDeserializer 使用 JSON 字符串中的属性值对创建一个类实例,而 JSONSerializer 接受一个类实例并创建一个 JSON 字符串。)
现在我还需要对 XML 使用类似的东西,最好的匹配是什么,是否有类似的东西但性能更好?
简单的例子
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);