为了得到这个结果:
{"aoColumnDefs":[{"aTargets":[0],"aDataSort":[0,1]},{"aTargets":[1],"aDataSort":[1,0]},{"aTargets":[2],"aDataSort":[2,3,4]}]}
拥有与以下相同的数据:
{ "aoColumnDefs": [ { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] }, { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] }, { "aDataSort": [ 2, 3, 4 ], "aTargets": [ 2 ] } ] }
您可以使用以下代码:
JSonObject jo = new JSonObject(); Collection<JSONObject> items = new ArrayList<JSONObject>(); JSonObject item1 = new JSonObject(); item1.put("aDataSort", new JSonArray(0, 1)); item1.put("aTargets", new JSonArray(0)); items.add(item1); JSonObject item2 = new JSonObject(); item2.put("aDataSort", new JSonArray(1, 0)); item2.put("aTargets", new JSonArray(1)); items.add(item2); JSonObject item3 = new JSonObject(); item3.put("aDataSort", new JSonArray(2, 3, 4)); item3.put("aTargets", new JSonArray(2)); items.add(item3); jo.put("aoColumnDefs", new JSonArray(items)); System.out.println(jo.toString());
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)