0

我的回复是这样的。。

{
    "IsSuccess": true,
    "ResponseObject": ["one", "two", "three", "four", "five"]
}}

我试图通过创建POJO. 请帮助我解决问题。

4

1 回答 1

4

你的 POJO 类应该是这样的。

public class TempParams {
    /**
     * IsSuccess : true
     * ResponseObject : ["one","two","three","four","five"]
     */

    private boolean IsSuccess;
    private List<String> ResponseObject;

    public boolean isIsSuccess() {
        return IsSuccess;
    }

    public void setIsSuccess(boolean IsSuccess) {
        this.IsSuccess = IsSuccess;
    }

    public List<String> getResponseObject() {
        return ResponseObject;
    }

    public void setResponseObject(List<String> ResponseObject) {
        this.ResponseObject = ResponseObject;
    }

}

成功获取响应对象后,您必须像这样转换它。

Gson gson = new Gson();
TempParams model = gson.fromJson(mObject.toString(), TempParams.class);

现在您可以从 POJO 类中获得价值。

于 2017-12-06T06:41:44.677 回答