chen-lhx
1、——————————————————————————————————————————————————————————————
import net.sf.json.JSONObject; String json = "{\"name\":\"lss\"}"; JSONObject jsonObj = JSONObject.fromObject(json); String name = jsonObj.getString("name"); Iterator it = jsonObj.keys(); List<String> keyListstr = new ArrayList<String>(); while(it.hasNext()){ key = (String) it.next();
     value = jsonObject.getString(key);
}

 

2、 {"info":[{"goodsId":"1234","goodsq":"10"},{"goodsId":"5678","goodsq":"20"}]}

2、———————————————————————————————————————————————————————————————
JSONObject jsonObject
= new JSONObject(jsonString);   JSONArray jsonArray =jsonObject.getJSONArray(“info”);   for (int i = 0; i < jsonArray.length(); i++) {   JSONObject jo = jsonArray.getJSONObject(i);        System.out.println(jo.getString("goodsld"));        System.out.println(jo.getString("goodsq")); }

 

分类:

技术点:

相关文章:

  • 2022-02-26
  • 2022-12-23
  • 2021-06-11
  • 2021-12-18
  • 2022-01-12
  • 2021-12-20
  • 2021-12-06
  • 2021-11-29
猜你喜欢
  • 2022-01-03
  • 2021-12-26
  • 2021-11-30
  • 2021-09-10
  • 2021-12-26
  • 2021-08-03
相关资源
相似解决方案