Currently I'm working on calling a JSON feed (from an URL) from within an Android application. Calling this URL is no problem, but I'm having a really annoying issue with my JSON output. Yesterday my JSON was working fine, but when I made a call to it today I'm getting an error that my string cannot be converted to a JSON object.
I printed the result to the console and the JSON string looked just fine.
{"message":{"success":false,"error":22}}
However, using the substring() method to obtain only the first character of the string, the output was:
·
I'm assuming this is an encoding issue, but I'm giving the following headers to my JSON feed:
content-type: application/json; charset=utf-8
I'm using the Yii-framework method CJSON::encode() to encode the data to JSON. It has always worked on me, until this morning. I set all my encoding to utf-8, but with no avail.
I also called to the JSON-feed from my browser, copied the JSON and used an online JSON validator, which gave me an 'Invalid JSON' result on the first line which is the '{' bracket. I removed the bracket and manually added it, validated the JSON again and the validator gave a 'Valid JSON' result.