tensory

关于JSON数据格式的基本知识和概念,参看:

http://www.cnblogs.com/zouzf/archive/2012/03/31/2426646.html

<span style="font-size:18px;">var = {
		"resultcode":"200",
		"reason":"Successed!",
		"result":
				{
					"lat":"41.2334465",
					"lng":"116.9772857",
					"type":"1",
					"address":"河北省承德市丰宁满族自治县",
					"business":"",
					"citycode":207,
					"ext":
						 {
							"adcode":"130826",
							"city":"承德市",
							"country":"中国",
							"direction":"",
							"distance":"",
							"district":"丰宁满族自治县",
							"province":"河北省",
							"street":"",
							"street_number":"",
							"country_code":0
						 }
				},
			"error_code":0
}</span>
例如,我想获得address,代码如下:

<span style="font-size:18px;">String currentLocation = null;
            try{
                JSONObject jsonObject = new JSONObject(var);
                JSONObject data = jsonObject.getJSONObject("result");
                currentLocation = data.getString("address");
            }catch (JSONException e){
                e.printStackTrace();
            }</span>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-01-01
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2021-06-07
  • 2021-10-25
  • 2022-12-23
相关资源
相似解决方案