反序列化json对象时出错

时间:2014-08-18 14:36:54

标签: java deserialization

我有一个

的json结构
{"data":[{"name":"value"}]}

我的这个json的pojo类是

public class RequestParamsDTO implements Serializable {

    private static final long serialVersionUID = -2440599796986757919L;

    private Object name;


    public Object getName() {
        return name;
    }

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

虽然反序列化这个json会引发错误,但我发现将Object声明为数据类型会导致问题,如果我将其更改为字符串或Integer它的工作原理,是否有人遇到此问题?

Reason for declared name as Object is
This name parameter will contain string or integer dynamically in run time,I have written an logic depands on it.

0 个答案:

没有答案