我在读取一个JSON数组:
JSONArray jArray = new JSONArray(jsonString);
System.out.println("*****JARRAY*****"+jArray.length());
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag","_id"+json_data.getInt("account")+
", mall_name"+json_data.getString("name")+
", location"+json_data.getString("number")+
", telephone"+json_data.getString("url")+
",----"+json_data.getString("balance")+
",----"+json_data.getString("credit")+
",----"+json_data.getString("displayName")
);
}
JSON语法文件的案例如下:
<code>
{
"list": [
{
"account": 1,
"name": "card",
"number": "xxxxx xxxx xxxx 2002",
"url": "http://www.google.com",
"balance": 1.0,
"credit": 1.0,
"displayName": "hsbc bank"
},
{
"account": 2,
"name": "card2",
"number": "xxxxx xxxx xxxx 3003",
"url": "http://www.google.com",
"balance": 2.0,
"credit": 2.0,
"displayName": "nsb bank"
}
],
"count": 2
}
</code>
语法前面都有一个花括号。当我执行这些代码块时,系统会报错说:
A JSONArray text must start with '[' at character 1 of....
有谁遇见过这样的问题吗?能提供案例的代码块更好,不胜感激~~