Genson genson = new Genson();
String json = genson.serialize(777.777); // the output will be 777.777
genson.serialize(true); // output is true (without quotes)
genson.deserialize("777", int.class); // deserializes it into 777
genson.deserialize("777.777", Object.class); // will return 777.777 (a double)
genson.deserialize("null", Object.class); // will return null;
Genson 0.92 发布,Java 的 JSON 映射库
Genson 0.92 发布,该版本集成 Jersey 提供自动检测功能,集成 Spring Web ,增强过滤支持,更好的用户自定义特性和对 URI、BigInteger、BigDecimal 和 Timestamp 的默认转换。
Genson 是一个轻量级的 Java 库用来处理 JSON 数据,提供了完全的数据绑定和 Java 泛型支持。
示例代码:
Genson genson = new Genson(); String json = genson.serialize(777.777); // the output will be 777.777 genson.serialize(true); // output is true (without quotes) genson.deserialize("777", int.class); // deserializes it into 777 genson.deserialize("777.777", Object.class); // will return 777.777 (a double) genson.deserialize("null", Object.class); // will return null;