This question already has an answer here:
这个问题在这里已有答案:
- How to add a URL String in a JSON object 2 answers
如何在JSON对象中添加URL字符串2个答案
I have a text which contains file path location. When I am trying to write this text path into a other json file using JSON object put method , I am getting \\
while my original text path contains \
.
我有一个包含文件路径位置的文本。当我尝试使用JSON对象put方法将此文本路径写入其他json文件时,我得到\\而我的原始文本路径包含\。
How can I avoid \\
?
我怎么能避免\\?
Please assist me on this.
请帮助我。
1 个解决方案
#1
1
Don't remove the slashes, because that's how the JSON standard is defined for when you show the entire object as a string. If you extract the string from the JSONObject then the slashes are removed.
不要删除斜杠,因为当您将整个对象显示为字符串时,这就是JSON标准的定义方式。如果从JSONObject中提取字符串,则会删除斜杠。
Edit: to find out the rules for how JSON changes string to it's own notation for "internal" use, see http://json.org/ for the string type.
编辑:找出JSON如何将字符串更改为自己的“内部”用法表示法的规则,请参阅http://json.org/获取字符串类型。
Still if you want to remove slash use string.replace from java or any other libraries or simply escape the character
如果你想从java或任何其他库中删除斜杠使用string.replace或者只是转义字符
#1
1
Don't remove the slashes, because that's how the JSON standard is defined for when you show the entire object as a string. If you extract the string from the JSONObject then the slashes are removed.
不要删除斜杠,因为当您将整个对象显示为字符串时,这就是JSON标准的定义方式。如果从JSONObject中提取字符串,则会删除斜杠。
Edit: to find out the rules for how JSON changes string to it's own notation for "internal" use, see http://json.org/ for the string type.
编辑:找出JSON如何将字符串更改为自己的“内部”用法表示法的规则,请参阅http://json.org/获取字符串类型。
Still if you want to remove slash use string.replace from java or any other libraries or simply escape the character
如果你想从java或任何其他库中删除斜杠使用string.replace或者只是转义字符