i am trying to Json parsing in my android app the link is https://www.buzzador.com/apps/present_software/webservice/index.php?op=ProductQ&campaign_id=607&userid=1077
char[] utf8 = null;
StringBuilder properString = new StringBuilder("");
utf8 = Response.toCharArray();
for (int i = 0; i < utf8.length; i++) {
if ((int) utf8[i] < 65000) {
properString.append(utf8[i]);
}
}
System.out.println("Response of Login::"
+ properString.toString());
To remove character like (\n) or unwanted character in json string used commons-lang3:3.4 library in program . i used this class to remove unwanted character in json string "StringEscapeUtils.unescapeJava(string)".
this will help you.
Had similar problem. At first my app was working great on both androids 4.0+ and 4.0- (2.3.3 2.2 etc). after a revision i have that problem. JSonarray could parse on 2.3.3
PROBLEM: Json STRING (response from server) comes with a character ' in front so actual response= '[{"1":"omg"}] and not the correct one [{"1":"omg"}]
Solution: if string dosent start with [ then edit response string (remove the ' character)
if (result.startsWith("["))
{
}
else
{
result= result.substring(1);
}
after then everything worked fine for me
If you are a using json-lib-2.4 as library, which I assume, you can parse strings with :
JSONSerializer.toJSON(yourString).toString()
instead of using the JsonObject class