Hy!JSON配列の問題
私はテレビチャンネルを持つJSON配列を持っていますが、配列の長さは3ですが、ツリーマップに送信した後の値は1つだけです。
try
{
JSONObject menuobj = this.getJSONObject("responseData");
Log.e("XXX", menuobj.toString());
JSONArray array = menuobj.getJSONArray("countries");
TreeMap<String, Integer> map = new TreeMap<String, Integer>();
for (int i = 0; i < array.length(); i++)
{
JSONObject obj = new JSONObject();
obj = array.getJSONObject(i);
if (obj.getString("name").equals(country))
{
Log.e("XXX2", obj.toString());
JSONArray arr = obj.getJSONArray("channels");
Log.e("XXX3", String.valueOf(arr.length()));
for (int j = 0; j < arr.length(); j++)
{
JSONObject obj2 = new JSONObject();
obj2 = arr.getJSONObject(i);
map.put(obj2.getString("name"), obj2.getInt("id"));
}
Log.e("XXX4", String.valueOf(map.size()));
return map;
}
}
LogCat:あなたが使用する必要が
02-01 18:24:20.277: ERROR/XXX(3784): {"countries":[{"id":"1","channels":[{"id":"3","name":"ARD"},{"id":"1","name":"ORF 1"},{"id":"2","name":"ORF 2"}],"name":"Ã?sterreich"},{"id":"2","channels":[{"id":"3","name":"ARD"}],"name":"Deutschland"}]}
02-01 18:24:20.288: ERROR/XXX2(3784): {"id":"1","channels":[{"id":"3","name":"ARD"},{"id":"1","name":"ORF 1"},{"id":"2","name":"ORF 2"}],"name":"Ã?sterreich"}
02-01 18:24:20.297: ERROR/XXX3(3784): 3
02-01 18:24:20.307: ERROR/XXX4(3784): 1
+1 - 良い点。 –
THX THX THX THX THX THX – user547995