我有一个名为responseObj的地图。
我已经在responseObj中添加了一些值,如下所示 -
用户类中的用户对象 -
现在我有一些问题 -
Map<String, object> responseObj = new HashMap<String, Object>();
我已经在responseObj中添加了一些值,如下所示 -
responseObj.put("canApprove", true); //1
responseObj.put("approvers", userList);
< p > < code > userList 是一个用户列表 -
List<User> userList = new ArrayList<User>();
用户类中的用户对象 -
class User {
private int userId;
private int roleId;
}
现在我有一些问题 -
Is it possible to convert the
responseObj
to a json so that"canApprove"
and"approvers"
become key of json (see the code snippent below) and how can I make it?{ "canApprove" : true, "approver": [ { "userId": 309, "roleId": 2009 }, { "userId": 3008, "roleId": 2009 },
] }
If I convert it into a json and get the response from jsp can I able get the appropriate boolean in jsp where the
"canApprove"
refers anObject
in theresponseObj
?Can I persist the
"userId" and "roleId"
to JSON fromUser
Class?