简体   繁体   English

从此JSON日期中删除转义字符的简单方法

[英]Simple way to remove escape characters from this JSON date

In my android application, my JSON date is returned as this: 在我的android应用程序中,我的JSON日期返回为:

\\/Date(1323752400000)\\/

Is there a simple way to remove the escape characters? 有一种简单的方法来删除转义符吗? (This is being sent from a WCF service to an Android application). (这是从WCF服务发送到Android应用程序的)。 I am already using StringEscapeUtils.unEscapeHtml4 to decode the entire serialized object. 我已经在使用StringEscapeUtils.unEscapeHtml4来解码整个序列化的对象。

actully this not works as it throws java.util.regex.PatternSyntaxException instead of using that use 实际上,这不起作用,因为它抛出java.util.regex.PatternSyntaxException而不是使用该用法

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

it works fine 它工作正常

On the receiving end, if you really want to, you could just do myJsonString = myJsonString.replaceAll("\\\\",""); 在接收端,如果您确实愿意,可以执行myJsonString = myJsonString.replaceAll("\\\\","");

But do note that those escape characters in no way make the JSON invalid or otherwise semantically different -- the '/' character can be optionally escaped with '\\' in JSON. 但请注意,这些转义字符绝不会使JSON无效或在语义上有所不同-可以选择在JSON中使用'\\'来对'/'字符进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM