new JSONParser method erroring out

64 views
Skip to first unread message

AlohaCode

unread,
Mar 1, 2014, 8:29:48 PM3/1/14
to codenameone...@googlegroups.com
I had a fully functioning JSON parsing implementation and then updated today from the newly depricated com.codename1.io.JSONParser.parse(reader) to JSONParser.parseJSON(reader) method and immediately started seeing the following error generated from within the parser's logic:  

java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.List
at com.codename1.io.JSONParser.getStackVec(JSONParser.java:373)
at com.codename1.io.JSONParser.stringToken(JSONParser.java:453)
at com.codename1.io.JSONParser.parse(JSONParser.java:119)
at com.codename1.io.JSONParser.parseJSON(JSONParser.java:343)
at userclasses.StateMachine$1.onLoad(StateMachine.java:117)
at com.codename1.components.WebBrowser$2.actionPerformed(WebBrowser.java:78)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:421)
at com.codename1.ui.util.EventDispatcher.access$400(EventDispatcher.java:41)
at com.codename1.ui.util.EventDispatcher$CallbackClass.run(EventDispatcher.java:101)
at com.codename1.ui.Display.processSerialCalls(Display.java:1075)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1019)
at com.codename1.ui.Display.mainEDTLoop(Display.java:925)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

My JSON message didn't change only the parser method.  The JSON message which produced the above error contains two simple JSON objects (simple key/value pairs).  Can anyone shed any light on this?  Mahalo!

AlohaCode

unread,
Mar 1, 2014, 8:35:54 PM3/1/14
to codenameone...@googlegroups.com
Here's my code...

GZConnectionRequest request = new GZConnectionRequest(){
Map<String, Object> mapJSONObjects = null;

protected void readUnzipedResponse(InputStream input) {
/* just read from the response input stream */
InputStreamReader reader = new InputStreamReader(input);
JSONParser parser = new JSONParser();
try {
mapJSONObjects = parser.parseJSON(reader);
} catch (IOException ex){
throw new RuntimeException(ex.getMessage());
}
}

protected void postResponse() { ...

Shai Almog

unread,
Mar 2, 2014, 1:09:55 AM3/2/14
to codenameone...@googlegroups.com
Hi,
there is a bug in the new parsing code. Just restore to the old parser until we release an update.
Notice that device builds should actually work since we fixed it there.

AlohaCode

unread,
Mar 2, 2014, 3:08:34 AM3/2/14
to codenameone...@googlegroups.com
Will do. Many thanks.
Reply all
Reply to author
Forward
0 new messages