求教json中存放对象问题的解决方法 jsonfckeditor 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String data="[{\"judge\":"+content+"}]"; 你这种对于普通变量行得通,但是变量是FckEditor类型的,里面的格式就像:<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>这样是通不过的! FckEditor类型 是什么类型???? http://jiangzhengjun.iteye.com/blog/841307看看可以解决 就是下载的一个文本编辑器,就像这个回复框一样,可以对文中进行编辑,也可以插入图片。获取的时候会有HTML标签,于是导致不好转化为json格式的数据,所以不能传过去! 他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行 搞不懂楼主,这根什么特殊字符有什么关系,你直接String data="[{\"judge\":"+content+"}]";这个content都是个字符串了,特殊字符又怎么了都在字符串里了,关特殊字符什么事 他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行嗯,我知道,就是感觉挺麻烦的,谢谢你了! 写个代码你看看:String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");String data="[{\"judge\":"+content+"}]";你觉得将上面的data能以json的格式传过去吗? 你要ajax输出给客户端?这样的话你用json-lib就是了 response.setContentType("application/json;charset=utf-8"); PrintWriter pw=response.getWriter(); String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>"; JSONObject jo=new JSONObject(); jo.accumulate("judge", content); JSONArray ja=new JSONArray(); ja.add(jo); pw.write(ja.toString()); pw.flush(); pw.close(); 直接工具转,或者 手动改为json的格式。 你要ajax输出给客户端?这样的话你用json-lib就是了 response.setContentType("application/json;charset=utf-8"); PrintWriter pw=response.getWriter(); String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>"; JSONObject jo=new JSONObject(); jo.accumulate("judge", content); JSONArray ja=new JSONArray(); ja.add(jo); pw.write(ja.toString()); pw.flush(); pw.close();非常霸气,我以前一直想用工具就是不知道工具的使用具体方法,刚刚用了一下,行得通,非常感谢! gson-1.7.1.jar这个jar推荐使用,可以用来转josn字符串的比json-lib-2.2.2-jdk15.jar给力一点~ 你要ajax输出给客户端?这样的话你用json-lib就是了 response.setContentType("application/json;charset=utf-8"); PrintWriter pw=response.getWriter(); String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>"; JSONObject jo=new JSONObject(); jo.accumulate("judge", content); JSONArray ja=new JSONArray(); ja.add(jo); pw.write(ja.toString()); pw.flush(); pw.close();但是刚刚发现这么用的话,前台的回调函数无法回调成功啊! 你要ajax输出给客户端?这样的话你用json-lib就是了 response.setContentType("application/json;charset=utf-8"); PrintWriter pw=response.getWriter(); String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>"; JSONObject jo=new JSONObject(); jo.accumulate("judge", content); JSONArray ja=new JSONArray(); ja.add(jo); pw.write(ja.toString()); pw.flush(); pw.close();但是刚刚发现这么用的话,前台的回调函数无法回调成功啊!其实是我自己的代码写错了,木事木事! 难道楼主还手动处理json不成?后端json.net前端json2表示接触ajax&json以来,就没手写过json 关于JAVA EE开发之框架选择,请教下 高手帮看下关于HQL语句查询问题,在线等,谢谢了! java中如何将字符串的编码从utf-8转换成gbk而且不会产生乱码(超过字符集的可以是?) 为什么浏览器端编程语言只有一个JavaScript?? 数据库 hibernate的保存问题 请问外派到ibm工作有没有前途? spring一对多,多对多关键字是? 类似Outlook日历的系统的简单开发 请问如何在输出得XML中去掉不需要得元素 JSTL Struts2中uri的小问题 linux tomcat 远程部署web项目问题 ContextLoaderListener
String data="[{\"judge\":"+content+"}]";
<h3><font color="blue">这里是数据测试</font></h3>
<p>sdf </p>这样是通不过的!
他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行
这个content都是个字符串了,特殊字符又怎么了都在字符串里了,关特殊字符什么事
他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行嗯,我知道,就是感觉挺麻烦的,谢谢你了!
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
你要ajax输出给客户端?这样的话你用json-lib就是了
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();非常霸气,我以前一直想用工具就是不知道工具的使用具体方法,刚刚用了一下,行得通,非常感谢!
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();但是刚刚发现这么用的话,前台的回调函数无法回调成功啊!
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();但是刚刚发现这么用的话,前台的回调函数无法回调成功啊!其实是我自己的代码写错了,木事木事!
后端json.net
前端json2
表示接触ajax&json以来,就没手写过json