I m using Volley library in android to get JsonObject from my server.
i have create the proper json in server with php
but when i get the json from server it occur a weird problem
i m using json_encode in php to produce json
i dont know what are these extra characters in front of json?
do you know how to solve this problem???
this is a error that i got in android
07-18 20:40:49.151: W/System.err(11636): com.android.volley.ParseError: org.json.JSONException: Value ï»? of type java.lang.String cannot be converted to JSONObject
thanks in advance
I would have posted this as a comment but I wanted to post the relevant code that is in the link. If it works, awesome, if not let me know and I will remove this (as I haven't tested it).
From Skip BOM
"The problem is that your UTF-8 string starts with a byte order mark character (BOM) '0xfeff'. We should fix our JSON parsers to skip this character if it exists.
As a workaround, you can use this code to strip the BOM when you go from InputStream to Reader."
public Reader inputStreamToReader(InputStream in) throws IOException {
in.mark(3);
int byte1 = in.read();
int byte2 = in.read();
if (byte1 == 0xFF && byte2 == 0xFE) {
return new InputStreamReader(in, "UTF-16LE");
} else if (byte1 == 0xFF && byte2 == 0xFF) {
return new InputStreamReader(in, "UTF-16BE");
} else {
int byte3 = in.read();
if (byte1 == 0xEF && byte2 == 0xBB && byte3 == 0xBF) {
return new InputStreamReader(in, "UTF-8");
} else {
in.reset();
return new InputStreamReader(in);
}
}
}
"Or you can remove the byte order mark from your file!"