这里只介绍一种方式,json转map
下面俩包 自行下载
下面是测试类(key是id)
public String Chang(String key){ BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(".\\src\\pro.js")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } StringBuilder sb=new StringBuilder(); String line=null; try { while((line=reader.readLine())!=null){ //把换行符去掉 sb.append(line); } reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } String str = sb.toString(); String newStr = str.substring(1,str.length()-1); Map map = FastJsonUtil.stringToCollect(newStr); String value = (String) map.get(""+key+""); return value; }
下面是json格式的 省市区县 配置文件
http://download.csdn.net/download/u010310183/9478708
原文链接:https://www.f2er.com/json/289417.html