Take the 2-minute tour ×

My JSON response contains characters in decimal format such as

My Friend&#39;s Story

instead of

My Friend's  Story

How do I convert them properly?

share|improve this question
show us an example JSON string. –  Buhake Sindi Nov 1 '10 at 16:56
Ask owner of the service to fix this, it looks like a bug in service, either using HTML encoding, or passing HTML encoded content directly. –  StaxMan Nov 2 '10 at 16:35
add comment

2 Answers

That's simple: You can use org.json.JSONTokener to solve your problem....

String json = "\"My Friend&#39;s Story\""; 
String value = (String)new JSONTokener(json).nextValue();
share|improve this answer
Why would that work? That's a HTML entity, not JSON quoting (which tokener would handle) –  StaxMan Nov 2 '10 at 16:34
@StaxMan, unfortunately Google didn't include XMLTokener (which is available on org.json site. My thought is that they probably included some html decoding in the JSONTokener. –  Buhake Sindi Nov 3 '10 at 9:15
add comment

Your Answer


