存入数据库时不想让带上\ 转义,
...... JdytripProductsDetailResponse response = ropClient.execute(request, session); if (response != null && response.isSuccess()) { ProductDetail productDetail = new ProductDetail(); productDetail.setProductId(Long.parseLong(response.getP_id())); Map<String,Object> map = new HashMap<String, Object>(); if (StringUtils.isNotNullOrEmptyStr(response.getFeature())) { map.put("feature",JSON.parse(response.getFeature()).toString()); // log.info("============="+JSON.toJSONString(response.getFeature())); } if (StringUtils.isNotNullOrEmptyStr(response.getStroke())) { map.put("stroke",JSON.parse(response.getStroke())); } if (StringUtils.isNotNullOrEmptyStr(response.getCost_in())) { map.put("cost_in",JSON.parse(response.getCost_in())); } if (StringUtils.isNotNullOrEmptyStr(response.getCost_noin())) { map.put("cost_noin",JSON.parse(response.getCost_noin())); } if (StringUtils.isNotNullOrEmptyStr(response.getNotice())) { map.put("notice",JSON.parse(response.getNotice())); } productDetail.setContent(net.sf.json.JSONObject.fromObject(map).toString()); // log.info("================"+net.sf.json.JSONObject.fromObject(map).toString().getBytes().length); productDetail.setTitle(response.getP_name()); productDetail.setVersion("1.0"); productDetailList.add(productDetail); } ......存入数据库的内容
{ "feature": { "title": "线路特色", "detail": "<p>【真纯玩】销售冠军,直营团,不加水、不进店、无购物,不推销, <br/>【发团快】划片区直发,各片区独立成团,勿需中转换乘,最快发团,最早回程,游览时间多出1小时<br/>【包接】解除路不熟、打车难的苦恼,轻松到家<br/>【豪华土家宴】仙女山星级酒店提供“农家八大碗”,非农家乐用餐环境可比 <br/>【导游好】亲妈般呵护、保姆级照顾,不催促、不赶路、配耳麦讲解 <br/>【不换乘】专享绿色通道,天坑入口、地缝出口无需排队换车,减少舟车劳顿 <br/>【赠品多】提供自拍杆、充电宝、矿泉水、雨衣(视天气)<br/>市场同类产品对比 <br/>自营团 其它团<br/>【发团】 不换车,快发团√ 需集散换车× <br/>【用餐】 豪华土家宴√ 农家乐桌餐× <br/>【购物】 坚决不进店√ 加水点购物× <br/>【导游】 好评导游耳麦讲解√ 推销较多×</p><p><br/></p><p><br/></p>" }, ...... } }更新一个更简便的方式:
String s1="{\"MsgId\":1,\"TotalCount\":10,\"FilterCount\":8,\"SentCount\":7,\"ErrorCount\":1}"; System.out.println(StringEscapeUtils.unescapeJava(s1));输出:
{"MsgId":1,"TotalCount":10,"FilterCount":8,"SentCount":7,"ErrorCount":1}