php5处理json就2个函数,很方便。但常用的java处理起来就很麻烦,通常用JSON-lib许多包--------下面有一个简单的java处理json的方法如下: 1:下载另外一个java的小包就可以了; http://www.JSON.org/java/json_simple.zip(当然是在win下的啦)里面有源码和文档例题和编程的lib包;编程只需要json_simple.jar这个包就行,才十几k。 2:在后端java中解析json的代码:a:把json字符串变成java数组对象形式:String s="[0,{/"1/":{/"2/":{/"3/":{/"4/":[5,{/"6/":7}]}}}}]"; Object obj=JSONValue.parse(s); JSONArray array=(JSONArray)obj; System.out.println(array.get(1));b:把java对象形式变成json字符串: JSONObject obj2=new JSONObject(); obj2.put("phone","123456"); obj2.put("zip","7890"); obj.put("contact",obj2); System.out.print(obj);c:把java数组形式变成json字符串: JSONArray array=new JSONArray(); array.add("hello"); array.add(new Integer(123)); array.add(new Boolean(false)); array.add(null); array.add(new Double(123.45)); array.add(obj2);//see above System.out.print(array);
http://sou.58.com/in?key=%E5%B7%A2%E6%B9%96%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%93%9C%E9%99%B5%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%9A%8C%E5%9F%A0%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%9E%A3%E5%BA%84%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8E%B1%E8%8A%9C%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8A%9C%E6%B9%96%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%98%9C%E9%98%B3%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%8D%97%E6%98%8C%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B5%8E%E5%AE%81%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E7%83%9F%E5%8F%B0%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%84%E5%8D%9A%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%AE%E5%8C%97%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%96%B0%E4%BD%99%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E4%B8%B4%E6%B2%82%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%BD%AE%E5%B7%9E%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8F%8F%E6%B3%BD%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%BE%B7%E5%B7%9E%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%AE%E5%8D%97%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%AE%89%E5%BA%86%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%90%88%E8%82%A5%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%9D%92%E5%B2%9B%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%97%A5%E7%85%A7%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%BD%8D%E5%9D%8A%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
3:前端的javascript中解析json的代码:var Json = {//把javascript的数组或对象转换成Json格式的字符串 toString: function(obj){ switch(typeof(obj)){ case 'string': return '"' + obj.replace(/(["//])/g, '//$1') + '"'; case 'array': return '[' + obj.map(Json.toString).join(',') + ']'; case 'object': var string = []; for (var property in obj) string.push(Json.toString(property) + ':' + Json.toString(obj[property])); return '{' + string.join(',') + '}'; case 'number': if (isFinite(obj)) break; case false: return 'null'; } return String(obj); },//把Json格式的字符串转换成javascript的数组或对象 evaluate: function(str, secure){ return ((typeof(str) != 'string') || (secure && !str.test(/^("(//.|[^"///n/r])*?"|[,:{}/[/]0-9./-+Eaeflnr-u /n/r/t])+?$/))) ? null : eval('(' + str + ')'); }
http://sou.58.com/in?key=%E5%B7%A2%E6%B9%96%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%93%9C%E9%99%B5%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%9A%8C%E5%9F%A0%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%9E%A3%E5%BA%84%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8E%B1%E8%8A%9C%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8A%9C%E6%B9%96%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%98%9C%E9%98%B3%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%8D%97%E6%98%8C%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B5%8E%E5%AE%81%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E7%83%9F%E5%8F%B0%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%84%E5%8D%9A%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%AE%E5%8C%97%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%96%B0%E4%BD%99%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E4%B8%B4%E6%B2%82%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%BD%AE%E5%B7%9E%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E8%8F%8F%E6%B3%BD%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%BE%B7%E5%B7%9E%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%B7%AE%E5%8D%97%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%AE%89%E5%BA%86%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E5%90%88%E8%82%A5%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E9%9D%92%E5%B2%9B%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%97%A5%E7%85%A7%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
http://sou.58.com/in?key=%E6%BD%8D%E5%9D%8A%E6%89%BE%E7%BE%8E%E5%A5%B3%E4%B8%8A%E9%97%A8%E6%9C%8D%E5%8A%A1%E3%80%90%E2%95%87%E5%BE%AE:82225031%E3%80%91
3:前端的javascript中解析json的代码:var Json = {//把javascript的数组或对象转换成Json格式的字符串 toString: function(obj){ switch(typeof(obj)){ case 'string': return '"' + obj.replace(/(["//])/g, '//$1') + '"'; case 'array': return '[' + obj.map(Json.toString).join(',') + ']'; case 'object': var string = []; for (var property in obj) string.push(Json.toString(property) + ':' + Json.toString(obj[property])); return '{' + string.join(',') + '}'; case 'number': if (isFinite(obj)) break; case false: return 'null'; } return String(obj); },//把Json格式的字符串转换成javascript的数组或对象 evaluate: function(str, secure){ return ((typeof(str) != 'string') || (secure && !str.test(/^("(//.|[^"///n/r])*?"|[,:{}/[/]0-9./-+Eaeflnr-u /n/r/t])+?$/))) ? null : eval('(' + str + ')'); }