Android 无法通过gson解析JsonArray

Android 无法通过gson解析JsonArray,android,json,gson,Android,Json,Gson,这是我的json: { "message":"Success", "method":"getList", "values": [ { "_id":"2" } ] } 有两个模型类: public class ModelList { @SerializedName("message") public String MESSAGE; @SerializedName("method")

这是我的
json

{
    "message":"Success",
    "method":"getList",
    "values": [
        {
            "_id":"2"
        }
    ]
}
有两个模型类:

public class ModelList {
    @SerializedName("message")
    public String MESSAGE;

    @SerializedName("method")
    public String METHOD;

    public List<ModelValue> modelValues;
}
这是我在活动中使用的代码

ModelList response;

response = gson.fromJson(jsonToStringFromAssetFolder("twitter_search.json", JsonParsingActivity.this),
    ModelArtistList.class);
Toast.makeText(this, response.MESSAGE, Toast.LENGTH_SHORT).show();

List<ModelValue> results = response.modelValues;

for (ModelValue result : results) {
    Toast.makeText(this, result._ID, Toast.LENGTH_SHORT).show();
    Log.e("log_tag","result.fromUser"+result._ID);
}
模型列表响应;
response=gson.fromJson(jsonToStringFromAssetFolder(“twitter_search.json”,JsonParsingActivity.this),
模型艺术家类);
Toast.makeText(this,response.MESSAGE,Toast.LENGTH_SHORT).show();
列出结果=response.modelValues;
对于(ModelValue结果:结果){
Toast.makeText(this,result.ID,Toast.LENGTH.SHORT).show();
Log.e(“Log_标签”,“result.fromUser”+result.\u ID);
}

我在:
List results=response.modelValues获得了
NullPointerException

我想您需要在
模型列表中使用这个类:为
模型值添加
@SerializedName(“值”)

public class ModelList {

    @SerializedName("message")
    public String MESSAGE;
    @SerializedName("method")
    public String METHOD;
    @SerializedName("values")
    public List<ModelValue> modelValues;
}
公共类模型列表{
@SerializedName(“消息”)
公共字符串消息;
@SerializedName(“方法”)
公共字符串方法;
@SerializedName(“值”)
公共价值清单;
}

这是您收到的唯一错误消息?它应该提供更多关于原因的细节
public class ModelList {

    @SerializedName("message")
    public String MESSAGE;
    @SerializedName("method")
    public String METHOD;
    @SerializedName("values")
    public List<ModelValue> modelValues;
}