1.需要的 jar 包
2.测试类
package testJson;
import net.sf.json.JSONObject;
public class TestJson {
public static void main(String[] args) {
String resultStr = "{ \"status\":\"OK\", \"result\":{ \"location\":{ \"lng\":121.477357, \"lat\":31.215912 }, \"precise\":1, \"confidence\":80, \"level\":\"\u9053\u8def\" }}";
JSONObject jsObj = JSONObject.fromObject(resultStr);
jsObj = (JSONObject) jsObj.get("result");
jsObj = (JSONObject) jsObj.get("location");
System.out.println(jsObj.get("lng").toString());
System.out.println(jsObj.get("lat").toString());
}
}