| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
openkk
12年前发布

Genson :一个快速、可扩展的JSON数据转换Java类库

Genson是一个开源的Java类库,用于实现Java到Json和 Json到Java的转换。Genson具备可扩展,并且还可配置,快速和易于使用。
示例代码:

class Person {   String fullName;   // will be converted even if it is private   @JsonProperty private Date birthDate;   Adress adress;   @JsonIgnore public int ignoredField;   private int privateNotDetected;   private Person() {}     @Creator public static Person create() {     return new Person();   }     public String getFullName(){    // will be used instead of direct field access   }  }    class Adress {    final int building;    final String street;    // only a constructor with arguments genson will use it during deserialization    public Adress(@JsonProperty("building") int building, @JsonProperty("street")  String street) {    }  }    Person someone = new Person("eugen", new GregorianCalendar(1986, 1, 16).getTime(), new Adress(157, "paris"));  // we obtain the following json string  //{"adress":{"building":157,"street":"paris"},"birthDate":"16 févr. 1986","happy":true,"fullName":"eugen"}  String json = genson.serialize(someone);     // now we deserialize it back  someone = genson.deserialize(json, Person.class);

项目主页:http://www.open-open.com/lib/view/home/1344926865991

 本文由用户 openkk 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1344926865991.html
JSON JSON开发包