{ 'status':0, 'message':'ok', 'result':[ { 'name':' 123', 'location':{ 'lat':rr, 'lng':ll }, 'uid':'e30da3876c4fdffb932ca3e8', 'city':'123', 'district':'116', 'business':'', 'cityid':'131' }, { 'name':'1212, 'location':{ 'lat':55, 'lng':ff }, 'uid':'1212', 'city':'成都市', 'district':'1212', 'business':'', 'cityid':'75' } ]}string类型的, 获取第一个的lat lng值package com.supermap.cyws.client;import org.codehaus.jettison.json.JSONArray;import org.codehaus.jettison.json.JSONObject;public class test {public static void main(String[] args) throws Exception {String ss="{ 'status':0, 'message':'ok', 'result':[ { 'name':'123',"+ "'location':{ 'lat':33, 'lng':77 }, business':'', 'cityid':'131' },"+ " {'business':'', 'cityid':'75' }] }"; JSONObject object=new JSONObject(ss); JSONArray resultJsonArray=(JSONArray) object.get("result"); JSONObject jsonObject=resultJsonArray.getJSONObject(0); JSONObject jsonObject2= (JSONObject) jsonObject.get("location"); String latString=jsonObject2.get("lat").toString(); String lngString= jsonObject2.get("lng").toString(); System.out.println(latString+","+lngString);}}
json 解析
最新推荐文章于 2023-01-18 23:09:33 发布