[英]Convert javascript json object into Java json object
I'm trying to convert the following script into java json, however I'm failing at "aTargets", [0]
我正在尝试将以下脚本转换为java json,但是在
"aTargets", [0]
失败"aTargets", [0]
I'm not sure how to create an array with just zero. 我不确定如何创建一个只有零的数组。
Script to be converted, 要转换的脚本,
var oTable = $('#example').dataTable( {
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"aaSorting": [[1, 'asc']]
});
My Java 我的Java
public JSONObject getOptions() {
JSONObject json = new JSONObject();
json.put("aoColumnDefs", new JSONArray()
//Failing here
.put(new JSONObject("bSortable", "false", "aTargets", "[0]")));
//Failing here too
json.put("aaSorting", new JSONArray(new JSONArray(1, 'asc')));
return json;
}
This is untested but I believe it's correct: 这未经测试,但我认为是正确的:
JSONObject json = new JSONObject();
json.put("aoColumnDefs", new JSONArray()
.put(new JSONObject("bSortable", "false", "aTargets", new JSONArray().put(0))));
json.put("aaSorting", new JSONArray().put(new JSONArray().put(1, "asc"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.