0

I have a JSON object with special character in it. The format is as follows:

"field1": "result1", "field2": "\uabc\udef\ughi" 

I get the string for each of the keys as

JSONObject jsonObj = new JSONObject();
String s1 = jsonObj.getString("field1");
String s2 = jsonObj.getString("field2");

When I print s2, I get weird characters as output. I know, "\u" is doing all the weirdness and I do not want that. I just want to get the string for field2 as it is. Sadly, I cannot modify the JSON object at source. Any solution to this scenario.

Arnab
  • 63
  • 3
  • 14
  • Looks like you should be able to fix it by encoding it then decoding it if I read this correctly. https://stackoverflow.com/questions/32056940/how-to-deal-with-backslashes-in-json-strings-php – J. Knight Jun 14 '17 at 04:06
  • if you know it's always present in field2 then why not replace \u with empty string? – karthick Jun 14 '17 at 04:08

0 Answers0