java使用json需要的包
http://download.csdn.net/download/qq_28958341/10142078
下面为依赖包的路径图,之后服务关闭重新配置下就可以使用了

关于json常用的方式有
后台向前台传送json数据
PrintWriter out = response.getWriter();//打开输出流
Map<String, Object> map = new HashMap<String, Object>();
map.put("userName", userName);
map.put("secreate", secreate);
//将数据存放在列表中
JSONObject json = JSONObject.fromObject(map);//转换成json字符串的形式
out.print(json);//向前台传送json字符串,这里很重要,这里为字符串
前台可以通过ajax的方式获取到数据
$.ajax({
type: "get",
url: "login",
async: true,
success: function(data) {
data = JSON.parse(data);//将json字符串转换为json对象,接收到的为json形式的字符串
alert(data);//[Object object]
},
error: function() {
alert("error!");
}
});