Skip to content

Instantly share code, notes, and snippets.

@wendal
Last active March 15, 2017 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wendal/5e8a20e6248f8a0e0ddc7483e451621b to your computer and use it in GitHub Desktop.
Save wendal/5e8a20e6248f8a0e0ddc7483e451621b to your computer and use it in GitHub Desktop.
测试nutz json 处理getter/setter的情况
package org.nutz.json.meta;
import org.nutz.json.Json;
import org.nutz.json.JsonField;
public class PojoForQQ {
private int id;
private String code;
@JsonField
public String getName() {
return id + code;
}
public void setName(String name) {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static void main(String[] args) {
PojoForQQ qq = new PojoForQQ();
qq.code = "abc";
qq.id = 123;
System.out.println(Json.toJson(qq));
}
}
@wendal
Copy link
Author

wendal commented Mar 15, 2017

1.r.60输出

{
   "id": 123,
   "code": "abc",
   "name": "123abc"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment