I am receiving the data from the service with the escape sequence characters…I have managed to elemenate them by this code
results=results.replace("\\\"", "\"");
if(results.startsWith("\"")) {
results=results.substring(1,results.length());
}
if(results.endsWith("\"")) {
results=results.substring(0,results.length()-1);
}
It works fine but for some strings it throws exception while creating json object…How do I automatically unescape the escape characters in the result, I have searched for answers but many of them saying to use a third party library…what is the best I can achieve this.
I think Apache Commons work pretty good. It has
StringEscapeUtilsclass with bunch of different static methods for escaping and unescaping strings, so i think you should check it.Good luck!