从Android中的Json String中删除反斜杠

编程入门 行业动态 更新时间:2024-10-14 10:39:45
本文介绍了从Android中的Json String中删除反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要一些帮助来从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\":\"jhjhjhj/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\"}"}

我从该字符串中删除反斜杠的目的

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":"absdds/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"}"}

给我惊喜

org.json.JSONException: Unterminated object at character 17 of {"response":"{"time_zone":"","session_token":"kjshhdscncnxzcxclx","user_login":"newoff2","user_profile_img":"abcd/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"}"}

如何使用适当的Json Formate删除此反斜杠?

How Can i remove this Back slash with Proper Json Formate ?

预先感谢

推荐答案

命令

result.replaceAll("\\","");

是正确的,如果您尝试使用在线json格式化程序显示服务器响应( jsonformatter.curiousconcept. com/),您可以清楚地看到该字符串的格式不正确.不需要在响应"后面加上双引号,而在结尾加上双引号.

is correct and if you try to display the server response with an online json formatter (jsonformatter.curiousconcept/) 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中删除反斜杠

本文发布于:2023-11-06 08:14:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   Android   Json   String

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!