json传object问题
我现在想做的是从请求中得到的json数据,该数据有object类型,那么我该在action中如何处理这个数据呢?
传递的数据如下:
var params = {userId: "xxx",user:{username:"111",userId:"222",school:"school"}}
我在action中 提供了 user变量,类型是object:有getxxx(),setxxx()方法:
private String userId;
private Object user;
public String execute() {
System.out.println("JsonPluginAction.execute()"+userId);
map.put("John", "Galt");
return SUCCESS;
}
其中我还定义一个自定义的类,该类有三个属性,分别对应username,userId,school.
那么请问我该如何才能将得到的JSON对象转换成user对象呢?
有人知道的麻烦详细解释下,先谢谢了。