1.将xml字符串转换为JSONObject字符串
org.json.JSONObject jsonObjectParent=XML.toJSONObject(josnStr);
2.解析JSONObject内容
如果解析的内容是json数据,就是带大括号的{},就用getJSONObject(),如果解析的内容json数组,就是带中括号[]的,就用
getJSONArray()
3.互相转换
JSONObject转JSONArray
org.json.JSONArray jsonArray = new org.json.JSONArray();
jsonArray.put(JSONObject)
JSONArray转JSONObject
JSONArray.get(index);
4.JSONObject转为实体对象
ZngStocks zngStocks = JSON.parseObject(String.valueOf(jsonObject), ZngStocks.class);