Problem when using Jackson json parser in Android.

I really like to use Jackson library to parse json string.

Just now met a problem

org.codehaus.jackson.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value

The reason is my string contains some newline symbols. Then actually the string is not "valid" or "formatted" Json . 

Finally I found one quick solution .


try {
    JSONObject b = new JSONObject(decodedPayload);
    decodedPayload = b.toString();
} catch (JSONException e) {
    e.printStackTrace();
}

That JSONObject can formatted that unformatted json string .

Might be there are some other better solution. 

Comments

Popular posts from this blog

A wired issue of MediaPlayer on Android

Gradle issue - peer not authenticated