从Android中的Json String中删除反斜杠 [英] Remove back slash from Json String in android
问题描述
我需要一些帮助来从Json String中删除反斜杠.
i need some help for Remove Back slash from Json String.
这是我从服务器端得到的响应.
Here is the Response which i Get From Server side.
"response":"{\"time_zone\":\"\",\"session_token\":\"abcdefgHijklomopqrstuvwxyz\",\"user_login\":\"abc\",\"user_profile_img\":\"http://jhjhjhj.org/system/photos/62/medium/images.jpg?1462446436\",\"success\":\"0\",\"org_admin\":\"\",\"user_id\":\"62\",\"user_org_id\":\"101\",\"phone_mobile\":\"510-427-9639\",\"user_email\":\"abc@pdmoffice.com\"}"}
我从该字符串中删除反斜杠的目的
what i have don for Remove Backslash from this String
result.replaceAll("\\",");
result.replaceAll("\\","");
than之后,它将给我这个不在Json Formate中的字符串.
than After it will give me This String which is not in Json Formate.
{"response":"{"time_zone":"","session_token":"nskfndkjfsfsdffjsdfd","user_login":"newoff2","user_profile_img":"http://absdds.org/system/photos/62/medium/images.jpg?1462446436","success":"0","org_admin":"","user_id":"62","user_org_id":"101","phone_mobile":"510-427-9639","user_email":"hjhjh@pdmoffice.com"}"}
给我惊喜
org.json.JSONException: Unterminated object at character 17 of
{"response":"{"time_zone":"","session_token":"kjshhdscncnxzcxclx","user_login":"newoff2","user_profile_img":"http://abcd.org/system/photos/62/medium/images.jpg?1462446436","success":"0","org_admin":"","user_id":"62","user_org_id":"101","phone_mobile":"510-427-9898","user_email":"sdgas@pdmoffice.com"}"}
如何使用适当的Json Formate删除此反斜杠?
How Can i remove this Back slash with Proper Json Formate ?
预先感谢
推荐答案
命令
result.replaceAll("\\","");
是正确的,如果您尝试使用在线json格式化程序显示服务器响应( https://jsonformatter.curiousconcept. com/),您可以清楚地看到该字符串的格式不正确.不需要在响应"后面加上双引号,而在结尾加上双引号.
is correct and if you try to display the server response with an online json formatter (https://jsonformatter.curiousconcept.com/) you can clearly see that the string is not correctly formatted. The double quotes after the "response" and one at the end are not required.
这篇关于从Android中的Json String中删除反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!