Skip to content Skip to sidebar Skip to footer

Gson Identifying Json Object As Primitive

I am writing a relatively simple messaging app that saves its logs in the JSON format, and I am using the GSON library to parse these. I load a JSON file from a server, and put it

Solution 1:

I'm guessing that the tabs are causing your issue. Try to remove them with:

content = content.replaceAll("\\s","")

this will simply clean your json string from any whitespace.

Btw I suggests you to get rid of Gson library and use directly the JSONObject provided in the android sdk. You can initialize it directly with the json string, as new JSONObject(content). :)

Post a Comment for "Gson Identifying Json Object As Primitive"