赞
踩
本位仅限于自己记录一下
- @RequestMapping("insert")
- public String insert(){
- JSONObject param = new JSONObject();
- JSONObject data = new JSONObject();
- JSONObject result = new JSONObject();
- data.put("ent_id","123");
- data.put("ent_name","zhongxin");
- result.put("data",data.toJSONString());
- param.put("name",result.toJSONString());
-
- testJsonServiceImpl.insert(param);
- return "success";
- }
插入到数据库的数据形式是下面这种:json对象内部的json对象的双引号是有转义的斜杠的,如果没有斜杠那么这种格式的数据查询出来使用 JSONObject.parseObject()方法
然后查询出来使用 JSONObject.parseObject()方法转换name字段,不会报错
- @RequestMapping("insert")
- public String insert(){
- JSONObject param = new JSONObject();
- JSONObject data = new JSONObject();
- JSONObject result = new JSONObject();
- data.put("ent_id","123");
- data.put("ent_name","zhongxin");
- // result.put("data",data.toJSONString());
- param.put("name",data.toJSONString());
-
- testJsonServiceImpl.insert(param);
- return "success";
- }
插入到数据库的格式是下面这种
查询出来使用 JSONObject.parseObject()方法转换name字段,不会报错
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。