json数据中特殊符号转json的问题

 

关于json数据中特殊符号转json的问题

原始数据:{"uri":"http://xxxx/Create","access_token":"YnN5a2NxbDRlZ2ZueTR0MW1mYWIxc3BuOmRlbW8xOjE6YjM5NDZjM2EtZGRiZC00MjdkLTllNDYtNjg4MWE1YmUzZjkzOjEwLjEwLjExLjIwNzoyMDE0LTEyLTg=","date":"2014-12-08"}

通过加密后:>'?@??p?M6?Uh?T68"? 

json:{"appKey":"xxxxxxxxxx","authInfo":"hmac-sha1 >'?@??p?M6?Uh?T68"?","paramInfo":{"uri":"http://test.com/TPlus11510/api/v1/saleDelivery/Create","access_token":"YnN5a2NxbDRlZ2ZueTR0MW1mYWIxc3BuOmRlbW8xOjE6YjM5NDZjM2EtZGRiZC00MjdkLTllNDYtNjg4MWE1YmUzZjkzOjEwLjEwLjExLjIwNzoyMDE0LTEyLTg=","date":"2014-12-08"}}

 

json字符串转json数据的时候报错

Map<String, Object> ret = JsonUtils.fromJson(json,  new TypeToken<Map<String, Object>>(){});

 

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 92

at com.google.gson.Gson.fromJson(Gson.java:818)

at com.google.gson.Gson.fromJson(Gson.java:768)

at com.google.gson.Gson.fromJson(Gson.java:717)

at com.hupun.chanjet.util.JsonUtils.fromJson(JsonUtils.java:298)

at com.hupun.chanjet.util.JsonUtils.fromJson(JsonUtils.java:318)

at com.hupun.chanjet.test.simple.SimpleSaleDeliveryCreateTest.main(SimpleSaleDeliveryCreateTest.java:74)

 

问题:hmac-sha1后的内容中有"导致json反转的问题.

 

sign = sign.replaceAll("\"", "\\\\\"");

sign = sign.replaceAll("'", "\'");

 

转化后的数据

json:{"appKey":"xxxxxxxxxxx","authInfo":"hmac-sha1 >'?@??p?M6?Uh?T68\"?","paramInfo":{"uri":"http://test.com/TPlus11510/api/v1/saleDelivery/Create","access_token":"YnN5a2NxbDRlZ2ZueTR0MW1mYWIxc3BuOmRlbW8xOjE6YjM5NDZjM2EtZGRiZC00MjdkLTllNDYtNjg4MWE1YmUzZjkzOjEwLjEwLjExLjIwNzoyMDE0LTEyLTg=","date":"2014-12-08"}}

 

你可能感兴趣的:(json数据中特殊符号转json的问题)