scripts= arrayToJson(scripts); node
function arrayToJson(o) {
var r = [];
if (typeof o == "string")
return "\"" + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n")
.replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\"";
if (typeof o == "object") {
if (!o.sort) {
for (var i in o)
r.push(i + ":" + arrayToJson(o[i]));
if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.
test(o.toString)) {
r.push("toString:" + o.toString.toString());
}
r = "{" + r.join() + "}";
} else {
for (var i = 0; i < o.length; i++) {
r.push(arrayToJson(o[i]));
}
r = "[" + r.join() + "]";
}
return r;
}
return o.toString();
}
數組
後臺 this
String scripts = request.getParameter("scripts"); spa
JSONArray mainArray=JSON.parseArray(scripts);
for (int i=0;i<mainArray.size();i++) {
String scripts_id = mainArray.getJSONObject(i).getString("script_id");
String scripts_show = mainArray.getJSONObject(i).getString("script_show");
String scripts_order = mainArray.getJSONObject(i).getString("script_order");
String script_type = mainArray.getJSONObject(i).getString("script_type");
String script_code = mainArray.getJSONObject(i).getString("script_code");
String script_name = mainArray.getJSONObject(i).getString("script_name");
} code