JSONParser returns longs as doubles

19 views
Skip to first unread message

howud...@gmail.com

unread,
Jun 29, 2016, 6:16:57 PM6/29/16
to CodenameOne Discussions
the json parser needs line 549 fixed.  even when useLongsDefault is set to true, the code parses as a double.  The reason is on line 549 of JSONParser:

    public void longToken(long tok) {
        if (isStackHash()) {
            getStackHash().put(currentKey, new Double(tok));  <<< not new Double, should be new Long(tok)
            currentKey = null;
        } else {
            getStackVec().add(new Long(tok));
        }
    }



howud...@gmail.com

unread,
Jun 29, 2016, 8:17:47 PM6/29/16
to CodenameOne Discussions, howud...@gmail.com
while we're at it, booleans shouldn't be added to the Map as Strings

Shai Almog

unread,
Jun 30, 2016, 12:11:02 AM6/30/16
to CodenameOne Discussions, howud...@gmail.com
FYI if you are already looking at the code it's pretty easy to just submit a pull request as explained here: https://www.codenameone.com/blog/how-to-use-the-codename-one-sources.html

If not please file an issue.
Reply all
Reply to author
Forward
0 new messages