使用 json jason 解析器,但我没有将多个标记值添加到数组列表中,我想将带有 Actor 的 $t 标记解析到数组列表中。例如
{
"media$group":{
"media$credit":[
{
"$t":"Murison Dunn",
"role":"Writer",
"scheme":"urn:ebu"
},
{
"$t":"Randolph Scott",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Forrest Tucker",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"name":"Mala Powers",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"J. Carrol Naish",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Edgar Buchanan",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"name":"Myron Healey",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Howard Petrie",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"name":"Ray Teal",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"William Forrest",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Denver Pyle",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Trevor Bardette",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Kenneth Tobey",
"role":"Actor",
"scheme":"urn:ebu"
}
]
},
{
"media$group":{
"media$credit":[
{
"$t":"Murison",
"role":"Writer",
"scheme":"urn:ebu"
},
{
"$t":"Scott",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Tucker",
"role":"Actor",
"scheme":"urn:ebu"
}
{
"name":"Powers",
"role":"Actor",
"scheme":"urn:ebu"
}
]
},
{
"media$group":{
"media$credit":[
{
"$t":"Dunn",
"role":"Writer",
"scheme":"urn:ebu"
},
{
"$t":"J.Naish",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Buchanan",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Healey",
"role":"Actor",
"scheme":"urn:ebu"
},
{
"$t":"Petrie",
"role":"Actor",
"scheme":"urn:ebu"
}
]
}
}
但是我的主要问题是我需要从 $t 标签中获取多个项目到数组列表中。我的代码是:
JSONObject jsonmediagrop=videoObject.getJSONObject("media$group");
JSONArray itemsmediarole = jsonmediagrop.getJSONArray("media$credit");
for(int l=0;l<itemsmediarole.length();l++){
JSONObject Objectrole = itemsmediarole.getJSONObject(l);
strrole=Objectrole.getString("Role");
Log.v("Role", strrole);
if(strrole.equals("Actor"))
{
stractor=Objectrole.getString("$t") + "," + stractor;
Log.v("stractor", stractor);
maprole.put("$t", stractor);
myrolelist.add(maprole);
}
}
myrolelist - 这是数组列表。maprole-这是哈希图。任何帮助表示赞赏。