json数组转字符串 前端与后端交互

$.ajax({
url: url,
type: "post",
dataType: "json",
traditional :true,//阻止jq的深度序列化
data: {traceListInfo:JSON.stringify(traceListInfo)},//jsonarr数组作为参数传后台需要转化为json字符串

}

后台接受json字符串转数组
JSONArray myJsonArray = JSONArray.parseArray(traceListInfo);
json数组遍历取值
Iterator<Object> it = ja.iterator();
while (it.hasNext()) {
JSONObject ob = (JSONObject) it.next();
value=ob.getString("num");
}

猜你喜欢

转载自www.cnblogs.com/dss1025/p/13163585.html
今日推荐