我的回答是这样的。
{
"IsSuccess": true,
"ResponseObject": ["one", "two", "three", "four", "five"]
}}
我试图通过创建
POJO
来做。请帮我解决。 最佳答案
您的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类中获取价值。