I have a client / server application written using Android and I use the standard org.json package classes bundled with Android to parse and create.
I get weird characters appearing on the server side right in the middle of the json lines generated, for example (not complete, because it's big):
{!lo":"es_MX","id":2791884,"os":"8"}
As you can see (!) The exclamation mark appears randomly instead of a double quote. I also get other random characters appearing in the middle of the line. It is very strange.
Here is the code that creates the JSON object ...
JSONObject jsonObject = new JSONObject(); jsonObject.put("key", someValue);
Here is the code that sends.
HttpPost type = new HttpPost(<server url here>); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("v", jsonObject.toString())); type.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); httpClient.execute(type);
I say a random but exclamation point in this exact position is consistent in many mistakes, but not every time. About 5 messages that receive this error are among tens of thousands per day. And usually this is not the contents of the values inserted in json, but the characters (such as the character above) that define the structure of the message, which tells me that this is not a character set problem.
Has anyone come across this?
source share