JSONObject.fromObject--JSON??????????????????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JSONObject.fromObject--JSON??????????????????相关的知识,希望对你有一定的参考价值。
?????????shm admin mob OLE Map?????? EDA from turn fun
1. List???????????????json??????
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
2. Map???????????????json??????
Map map = new HashMap();
map.put("name", "json");
map.put("bool", Boolean.TRUE);
map.put("int", new Integer(1));
map.put("arr", new String[] { "a", "b" });
map.put("func", "function(i){ return this.arr[i]; }");
JSONObject json = JSONObject.fromObject(map);
3. Bean?????????json??????
JSONObject jsonObject = JSONObject.fromObject(new JsonBean());
4. ???????????????json??????
boolean[] boolArray = new boolean[] { true, false, true };
JSONArray jsonArray1 = JSONArray.fromObject(boolArray);
5. ?????????????????????json??????
JSONArray jsonArray3 = JSONArray.fromObject("[???json???,???is???,???easy???]" );
List<Role> roleList = roleService.selectRole(conditions);
if(roleList.size()>0)
{
Role role = roleList.get(0);
role.setAddOrEdit("update");
result = JSONObject.fromObject(role);
}
return : {addOrEdit: "update", createBy: "admin", createDate: {???}, roleId: "SALES_55b1dcd69aa64be6845bafef1e04707a", roleName: "test1", ???}
以上是关于JSONObject.fromObject--JSON??????????????????的主要内容,如果未能解决你的问题,请参考以下文章