Error occurs when parsing JSON with GSON...HELP NEEDED!!!

1,323 views
Skip to first unread message

Muthiah Subbiah

unread,
Sep 21, 2012, 3:43:31 PM9/21/12
to googl...@googlegroups.com
I have a an android app that is trying to parse the JSON from a webservice with a GSON Parser, but I keep getting this error:

09-20 15:58:50.835: E/ServiceGateWay(216): Invalid Json String : com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY

The frustrating thing is I don't know how to find at what line it's blowing up. Every time I debug in Eclipse and I walk through the code and I try to step into the part where the code assigns the response to the response class, but Eclipse throws this error:

["SOURCE NOT FOUND"
The JAR file gson-2.0.jar has no source attachment.]

I have checked my JSON response (it's formatting is valid). Does anyone know how I can figure out the exact line where the error occurs?

Thanks,
Mike

Inderjeet Singh

unread,
Sep 21, 2012, 4:19:09 PM9/21/12
to googl...@googlegroups.com
You can improve your debugging by getting the Gson source jar from the maven repository. Here is a link to version 2.2.2: 

I think most likely what is happening is that one of the field is of type String but the input is a Json array. So your JSON is valid, it is just different from what is expected.

HTH
Inder
Reply all
Reply to author
Forward
0 new messages