0

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?

fracz
  • 20,536
  • 18
  • 103
  • 149
TheCodeCache
  • 820
  • 1
  • 7
  • 27

1 Answers1

3

They are the same, as you can see in the sources:

public static final CharSequenceTranslator UNESCAPE_JSON = UNESCAPE_JAVA;

fracz
  • 20,536
  • 18
  • 103
  • 149
  • Thanks for clarification, I got it now, but will accept the answer after 3 minutes as SO does not allow to accept till it completes 3 minutes : D – TheCodeCache Aug 05 '20 at 14:19