Android parses special characters in JSON responses… here is a solution to the problem.
Android parses special characters in JSON responses
In my Android app, I get the JSON response string from the PHP url. From the response I get some hotel names with an apostrophe and I get the '
character instead of the apostrophe
. How do I parse hotels with special characters in Android?
I can see the apostrophe in the browser, but not in android logcat.
I tried jresponse = URLEncoder.encode(jresponse, "UTF-8");
But I can’t get an apostrophe
for the hotel name.
This is one of the hotel names in the response.
I see the following in browser.
{"id":12747,
"name":"Oscar's",
....
}
But in the logcat:
id 12747
name Oscar' s
Solution
Use decoder instead of encoder. URLDecoder.decode(jresponse,"UTF-8")