1.下面的代码返回从服务器取来的JSon类型数据 json
result = new String(EntityUtils.toString(response.getEntity(),
2.JSON对象是{}内的数据,数据以数据对方式给出,如“name”:"william".一个JSon对象里面可能包含其余JSon对象。[]表示JSon对象数组,里面包含多个JSon对象。 数组
下面是一条json数据(String类型): 服务器
{"profile":[{"name":"william","age":28},{"name":"jack","age":30}]"} spa
解析过程: 对象
JSONObject jsonobject=new JSONObject(string); utf-8
JSONArray jsonarray=jsonobject.getJSONArray("profile"); get
JSONObject tempJSon; string
for(int i=0;i<jsonarray.length;i++){ it
tempJSon=jsonarray.getJSONObject(i); object
//对取到的JSONObject对象进行处理
...
}