删除“\”在json对象字符串中 [英] Removing "\" in json object string
本文介绍了删除“\”在json对象字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何删除下面字符串中的特殊字符\:
How can i remove special character "\" in the string below:
String x = {
"message": {
"@content": "toom"
},
"recipients": "[{\"@id\":\"1000001865\"}]",
"room": {
"@subject": "room"
}
}
我使用了x.replaceAll(\\,),但它不起作用。
I used x.replaceAll("\\","") but it does not work.
推荐答案
你必须逃避正则表达式中的反斜杠。
You must escape the backslash in the regex.
试试
x.replaceAll("\\\\", "")
请参阅 JavaRegularExpressions:3.6。 Java中的反斜杠
这篇关于删除“\”在json对象字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文