0

I have the following JSON data:

{
    "response": {},
    "errorMessage": {
        "error": [
            {
                "errorId": 260003,
                "domain": "ads",
                "subdomain": "asd",
                "severity": "asd",
                "category": "asd",
                "message": "asdsa  asd ad",
                "errorName": "UnAuthorized"
            }
        ]
    }
}

Currently I have the following class structure:

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;

I have setters/get set for all private variables

But when I do a JSONCollection cJson = gson.fromJson(JSONValue,JSONCollection.class); I get cJson as a null.

How to get it right?

4

1 回答 1

1

我使用@JigarJoshi 展示的这个工具来生成我的模式。

我发现的唯一区别是我必须将类名从更改ErrorValuesError

于 2013-07-22T19:07:42.393 回答