Java代码: dept.json就是高德接口返回的完整json,我保存到了本地处理的。
public class LocationTest {
public static void main(String[] args) throws IOException {
initDb();
//高德的接口描述页面
//http://lbs.amap.com/api/webservice/guide/api/district/#district
//接口地址
//http://restapi.amap.com/v3/config/district?key=&keywords=中国&subdistrict=3&showbiz=false&extensions=base
File file = new File("C:\\Users\\tj\\Desktop\\dept.json");
String s = FileUtils.readFileToString(file, "utf-8");
JSONObject o = JSON.parseObject(s).getJSONArray("districts").getJSONObject(0);
save(o, 0, ",0,",1);
}
static int id = 10000;
public static int nextId(){
id++;
return id;
}
public static void save(JSONObject o,int pid,String ppath,int