The string returned by php is stored in result. If I print the result in console, it shows the correct json contents. But THe JSONObject cant parse it. If I copy and paste the json content from log and use escape sequence for '"', the program works as intended. Some said that I need to do utf without bom. I converted it to that from notepad ++. But it still doesnt work.