在java代码中显示json字符串(怎么避免json字符串中双引号在java代码中显示)
String log = "eyJvcmRlckluZm8iOnsiaWQiOjEwNzQwNCwib3JkZXJJZCI6MjczNjQyMSwicHJvZHVjdENvZGUiOjQ1NzM3MywicHJvZHVjdE5hbWUiOiJcdTAwMjZsdDvmoYLmnpct6LGh5bGxLeWFtOWdqua8k+axny3pmLPmnJQt6J206J225rOJ5Y+M6aOeNOaXpea4uFx1MDAyNmd0O+WmgueUu+W5v+ilv++8jOWwj+i1hOmYs+aclCIsImFkdWx0Q291bnQiOjQsImNoaWxkQ291bnQiOjAsInN0YXJ0RGF0ZSI6IlNlcCAzLCAyMDEzIDEyOjAwOjAwIEFNIiwiZW5kRGF0ZSI6IlNlcCA2LCAyMDEzIDEyOjAwOjAwIEFNIiwidmVuZG9ySWQiOjY2ODgsInZlbmRvck5hbWUiOiLljJfmtbfmtbflpJYo5LiK5rW35YqeKSIsIm9yZGVyU3RhdHVzIjoxLCJyb3V0ZVR5cGUiOjEsInByb2R1Y3RTcGVjaWFsaXN0Ijoi6ZmI5rabIiwicHJvZHVjdE1hbmFnZXIiOiLovpvoi5ciLCJjb250YWN0TmFtZSI6Iui1tea2myIsIm9yZGVyU3lzdGVtVHlwZSI6MSwic2VuZFN0YXR1cyI6MSwiYmVnaW5DaXR5Q29kZSI6MjUwMCwiY29uZmlybVRpbWUiOiJBdWcgMjksIDIwMTMgMTI6MDA6MDAgQU0iLCJzdGF0dXMiOjEsImN1c3RvbWVySWRzIjoiIiwiY29uZmlybVN0YXR1cyI6MiwiZGVsRmxhZyI6MH0sInByb2R1Y3RJbmZvIjp7ImlkIjoyODQwNiwib3JkZXJJZCI6MjczNjQyMSwic2VuZFR5cGUiOiLor7fmkLrluKbmnInmlYjor4Hku7bljp/ku7bvvIzoh7PlsJHlnKjotbfpo57ml7bpl7TliY05MOWIhumSn+aKtei+vuacuuWcuu+8iOm7hOmHkeWRqOacn+mXtOW7uuiuruaPkOWJjTEyMOWIhumSn++8ie+8jOiHqu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lQ2l0eUNvZGUiOjcwNX0seyJpZCI6NjUwOTIsInRhYmxlTmFtZSI6Im50Y19wcm9kdWN0X2luZm8iLCJvYmplY3RJZCI6MTA3NDA0LCJ0cmFmZmljVGF4IjoyLCJ0cmFmZmljVHlwZSI6Miwic3RhcnRQb2ludCI6IuS4pOaxn+WbvemZheacuuWcuiIsImFycml2ZVBvaW50Ijoi5rWm5Lic5Zu96ZmF5py65Zy6Iiwic3RhcnRUaW1lIjoiMjAxMy0wOS0wNiAxMToxMDowMCIsImFycml2ZVRpbWUiOiIyMDEzLTA5LTA2IDEzOjIwOjAwIiwidHJhZmZpY051bWJlciI6IkhPMTE0OCIsInN0YXJ0QWlycG9ydFRlcm1pbmFsIjoiIiwiYXJyaXZlQWlycG9ydFRlcm1pbmFsIjoiVDIiLCJmbGlnaHRTdG9wRmxhZyI6MCwiZmxpZ2h0U3RvcEFpcnBvcnQiOiIiLCJmbGlnaHRTdG9wTWludXRlIjowLCJyZW1hcmsiOiIiLCJiZWdpbkNpdHkiOiLmoYLmnpciLCJhcnJpdmVDaXR5Ijoi5LiK5rW3IiwiYmVnaW5DaXR5Q29kZSI6NzA1LCJhcnJpdmVDaXR5Q29kZSI6MjUwMH1dLCJ0cmlwIjp7ImlkIjoyODU4MCwidGFibGVOYW1lIjoibnRjX3Byb2R1Y3RfaW5mbyIsIm9iamVjdElkIjoxMDc0MDQsImNvbnRlbnQiOiIifSwibmJCYXRjaEZsYWciOmZhbHNlLCJhdHRhY2hMaXN0IjpbXX0=";
BASE64Decoder decoder = new BASE64Decoder();
try {
log = new String(decoder.decodeBuffer(log));
System.out.println(log);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
结果是
{"orderInfo":{"id":107404,"orderId":2736421,"productCode":457373,"productName":"\u0026lt;桂林-象山-兴坪漓江-阳朔-蝴蝶泉双飞4日游\u0026gt;如画广西,小资阳朔","adultCount":4,"childCount":0,"startDate":"Sep 3, 2013 12:00:00 AM","endDate":"Sep 6, 2013 12:00:00 AM","vendorId":6688,"vendorName":"北海海外(上海办)","orderStatus":1,"routeType":1,"productSpecialist":"陈涛","productManager":"辛苗","contactName":"赵涛","orderSystemType":1,"sendStatus":1,"beginCityCode":2500,"confirmTime":"Aug 29, 2013 12:00:00 AM","status":1,"customerIds":"","confirmStatus":2,"delFlag":0},"productInfo":{"id":28406,"orderId":2736421,"sendType":"请携带有效证件原件,至少在起飞时间前90分钟抵达机场(黄金周期间建议提前120分钟),自行办理相关登机手续;航班办理中如遇到任何问题,请咨询机场工作人员或者打途牛电话:4007-999999转9号键。","sendPerson":"","sendPersonPhone":"","meetPersonPhone":"","meetType":"导游会于最晚您到达桂林当天和您联系,具体事宜以导游通知为。\nPS:导游人员会根据此团所有途牛会员的航班,在行程不减少的情况下,先后顺序会有所调整,敬请留意!","meetPerson":"","guideName":"","guidePhone":"","contactName":"娜娜(此线路投诉专员)","contactPhone":"13501786855","contactName1":"郑微","contactPhone1":"15977335656","venueMark":"","venueTime":"","venue":"","leaderName":"","leaderPhone":"","abroadVenueMark":"","hotelInfo":"","remark":"1、出游时,请携带出团通知书及签约行程,方便您查询相关信息;\n2、导游会在最晚出游当天和您联系,请保证手机信号通畅;旅途中如产生任何问题可随时致电此线路全程质量跟踪员——娜娜,她会第一时间解决您的问题。","notice":"","editMinute":0,"editSystemType":2,"updateUserName":"","updateTime":"Aug 29, 2013 11:55:25 AM","delFlag":0},"trafficList":[{"id":65091,"tableName":"ntc_product_info","objectId":107404,"trafficTax":1,"trafficType":2,"startPoint":"浦东国际机场","arrivePoint":"两江国际机场","startTime":"2013-09-03 08:00:00","arriveTime":"2013-09-03 10:20:00","trafficNumber":"HO1147","startAirportTerminal":"T2","arriveAirportTerminal":"","flightStopFlag":0,"flightStopAirport":"","flightStopMinute":0,"remark":"","beginCity":"上海","arriveCity":"桂林","beginCityCode":2500,"arriveCityCode":705},{"id":65092,"tableName":"ntc_product_info","objectId":107404,"trafficTax":2,"trafficType":2,"startPoint":"两江国际机场","arrivePoint":"浦东国际机场","startTime":"2013-09-06 11:10:00","arriveTime":"2013-09-06 13:20:00","trafficNumber":"HO1148","startAirportTerminal":"","arriveAirportTerminal":"T2","flightStopFlag":0,"flightStopAirport":"","flightStopMinute":0,"remark":"","beginCity":"桂林","arriveCity":"上海","beginCityCode":705,"arriveCityCode":2500}],"trip":{"id":28580,"tableName":"ntc_product_info","objectId":107404,"content":""},"nbBatchFlag":false,"attachList":[]}
如果直接将json字符串写在java代码里,处理json字符串中的双引号非常麻烦。这种先加密,后解密的方法巧妙的避开了这种困难。