Chinaunix首页 | 论坛 | 博客
  • 博客访问: 530159
  • 博文数量: 135
  • 博客积分: 3568
  • 博客等级: 中校
  • 技术积分: 1942
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-19 17:52
文章分类

全部博文(135)

文章存档

2012年(29)

2011年(41)

2010年(26)

2009年(12)

2008年(9)

2007年(12)

2006年(6)

分类: Java

2010-06-22 23:19:45

Lib:
commons-beanutils-1.8.2.jar
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-io-1.4.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
ezmorph-1.0.6.jar
json-lib-2.3-jdk15.jar


文件:test.zip
大小:6KB
下载:下载


Person.java

package test.json;

import java.util.Date;
import java.util.List;
import java.util.Map;

public class Person {

    private static final long serialVersionUID = 1L;

    private String name;

    private Integer age;

    private boolean male;

    private Date birthday;

    private String[] alias;

    private byte[] imageData;

    private List<String> favors;

    private Map<String, String> addrs;

    private Object nullObject = null;

    private Person parent;

    private Person child;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public boolean isMale() {
        return male;
    }

    public void setMale(boolean male) {
        this.male = male;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String[] getAlias() {
        return alias;
    }

    public void setAlias(String[] alias) {
        this.alias = alias;
    }

    public byte[] getImageData() {
        return imageData;
    }

    public void setImageData(byte[] imageData) {
        this.imageData = imageData;
    }

    public List<String> getFavors() {
        return favors;
    }

    public void setFavors(List<String> favors) {
        this.favors = favors;
    }

    public Map<String, String> getAddrs() {
        return addrs;
    }

    public void setAddrs(Map<String, String> addrs) {
        this.addrs = addrs;
    }

    public Person getParent() {
        return parent;
    }

    public void setParent(Person parent) {
        this.parent = parent;
    }

    public Person getChild() {
        return child;
    }

    public void setChild(Person child) {
        this.child = child;
    }

    public Object getNullObject() {
        return nullObject;
    }

    public void setNullObject(Object nullObject) {
        this.nullObject = null;
    }
}



Output:


----------JsonUtilTest#testGetInstance01()-----

{
  "addrs": {
    "SD": "ShanDong",
    "HN": "HeNan"
  },
  "age": 25,
  "alias": [
    "S_A_0",
    "S_A_1",
    "S_A_2"
  ],
  "birthday": "1985-05-05 05:05:05,005",
  "child": null,
  "favors": [
    "S_F_0",
    "S_F_1",
    "S_F_2",
    " test \n\t<>,\"\"_'ABC'&&|| "
  ],
  "imageData": "AQIDBA==\r\n",
  "male": true,
  "name": "son",
  "nullObject": null,
  "parent": {
    "addrs": {
      "TJ": "TianJin",
      "BJ": "BeiJing"
    },
    "age": 50,
    "alias": [
      "M_A_0",
      "M_A_1",
      "M_A_2"
    ],
    "birthday": "1960-06-06 06:06:06,006",
    "child": null,
    "favors": [
      "M_F_0",
      "M_F_1",
      "M_F_2"
    ],
    "imageData": "ChQeKA==\r\n",
    "male": false,
    "name": "mom",
    "nullObject": null,
    "parent": null
  }
}

----------JsonUtilTest#testGetInstance02()---------------

{
  "addrs": null,
  "age": null,
  "alias": null,
  "birthday": null,
  "child": null,
  "favors": null,
  "imageData": null,
  "male": false,
  "name": null,
  "nullObject": null,
  "parent": null
}


阅读(556) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~