我有以下JSON数据:
{
"response": {},
"errorMessage": {
"error": [
{
"errorId": 260003,
"domain": "ads",
"subdomain": "asd",
"severity": "asd",
"category": "asd",
"message": "asdsa asd ad",
"errorName": "UnAuthorized"
}
]
}
}
目前我有以下的类结构:
public class JSONCollection
private Response response;
private ErrorMessage error;
public class Response
private String collectionId;
private String url;
public class ErrorMessage
private List<ErrorValues> error;
public class ErrorValues
private String errorId;
private String domain;
private String subdomain;
private String severity;
private String category;
private String message;
private String errorName;
我为所有私有变量设置了setter/get set
但是当我做JSONCollection cJson = gson.fromJson(JSONValue,JSONCollection.class);
时,我得到的cJson是null
。
如何做好呢?
1条答案
按热度按时间zzoitvuj1#
我使用@JigarJoshi所示的this tool来生成我的模式。
我发现的唯一区别是必须将类名从
ErrorValues
更改为Error