字符串格式如下,[{"FirstIndexId":"901","SecondIndexId":"長春","SecondIndexName":"2G基站","IndexArriveValue":""},{"FirstIndexId":"901","SecondIndexId":"長春","SecondIndexName":"2G基站","IndexArriveValue":""}]前臺通過ajax JSON.stringify得到的字符串String格式。
2 回答

慕絲7291255
TA貢獻1859條經驗 獲得超6個贊
String msg="[{"FirstIndexId":"901","SecondIndexId":"長春","SecondIndexName":"2G基站","IndexArriveValue":""},{"FirstIndexId":"901","SecondIndexId":"長春","SecondIndexName":"2G基站","IndexArriveValue":""}]";
JSONArray resultJsonArray = JSONArray.fromObject(msg);
for (int i = 0; i < resultJsonArray.size(); i++) {
JSONObject row = (JSONObject)resultJsonArray.get(i);
String FirstIndexId = (String)row.get("FirstIndexId");
}

12345678_0001
TA貢獻1802條經驗 獲得超5個贊
引用第三方json解析包,層層解析;
gson、fastjson、jackson等
解析后格式有JSONObject,JSONArray兩種,分別對應鍵值對和數組。
調用其parseObject、parseArray方法
或者定義javabean和上面的結構一一對應,調用其parse方法
調用主體有JSON、JSONArray、JSONObject
添加回答
舉報
0/150
提交
取消