主要活动代码片段......我已经尝试过responce.getObject但它没有工作......
JsonArrayRequest request = new JsonArrayRequest( Request.Method.GET,
URL,
null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (response == null) {
Toast.makeText(getApplicationContext(), "Couldn't fetch the menu! Pleas try again.", Toast.LENGTH_LONG).show();
return;
}
List<Person> persons = new Gson().fromJson(response.toString(), new TypeToken<List<Person>>() {
}.getType());
// adding persons to cart list
cartList.clear();
cartList.addAll(persons);
我的json文件
{
"code": 1200,
"message": "Data Retrieved",
"data": [
{
"id": 1,
"name": "Vangipurapu Venkata Sai Laxman",
"skills": "Cricketer, Batsman",
"image": "https://qph.ec.quoracdn.net/main-qimg-4f5029c4319b41270f5643d461979645-c"
},
{
"id": 2,
"name": "Himesh Reshammiya",
"skills": "music director, singer, producer, lyricist, distributor and actor",
"image": "https://starsunfolded-1ygkv60km.netdna-ssl.com/wp-content/uploads/2016/01/Himesh-Reshammiya-nasal-singing.jpg"
}
]
}
如何识别对象“数据”并访问所有数组。