英文:
What is the difference between unescapeJava and unescapeJson from StringEscapeUtils
问题
根据StringEscapeUtils文档,似乎这两个方法unescapeJson
和unescapeJava
执行的是类似的操作。
我尝试使用这两种方法,它们都正常工作,如下所示:
示例:
String input = ""{"key":"ab\u2019cd"}"";
System.out.println(unescapeJava(input)); // 输出:{"key":"ab’cd"}
System.out.println(unescapeJson(input)); // 输出:{"key":"ab’cd"}
这两个语句打印的输出完全相同。那么,它们之间有什么区别,以及何时使用哪种方法?
英文:
As per the StringEscapeUtils documentation, looks like both these methods unescapeJson
and unescapeJava
does the similar thing.
I tried using both methods it works fine as below:
Example:
String input = "{\"key\":\"ab\u2019cd\"}"
System.out.println(unescapeJava(input)); // outputs: {"key":"ab’cd"}
System.out.println(unescapeJson(input)); // outputs: {"key":"ab’cd"}
Both of these statements print exactly same output. So, what is the difference and when to use which method?
答案1
得分: 3
They are the same, as you can see in the sources:
public static final CharSequenceTranslator UNESCAPE_JSON = UNESCAPE_JAVA;
英文:
They are the same, as you can see in the sources:
public static final CharSequenceTranslator UNESCAPE_JSON = UNESCAPE_JAVA;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论