0

I have an app that uses Parse as a backend. Parse calls a web scraper which returns a string to Parse and I have to use stringify on the string I received because it's not always allowed to be sent over the network otherwise. Once I stringify that string how can I parse it in Java so that I have the original returned string. For instance, how do I go from this stringified string in javascript

"\"This is a string\"\r\n\t\t"

To this string in java

"This is a string"

To reiterate, I start with a String (such as "This is a string") but then have to stringify that to send it over the network (result "\"This is a string\"\r\n\t\t"). Once I return the stringified string to my android app, how can I get back the original string ("This is a string")?

thailey01
  • 165
  • 1
  • 14
  • See [Howto unescape a Java string literal in Java](http://stackoverflow.com/questions/3537706/howto-unescape-a-java-string-literal-in-java). –  Jan 16 '16 at 08:22

1 Answers1

1

Try StringEscapeUtils from apache commons

String input = "\"This is a string\"\r\n\t\t";

String output = StringEscapeUtils.unescapeJava(input);

System.out.println(output);

"This is a string"
Anoop LL
  • 1,548
  • 2
  • 21
  • 32
  • Thanks for the help, but I went ahead and used quite regex expression to take out escape characters. I didn't want to download a library that I would only need for one thing. – thailey01 Jan 16 '16 at 17:20