tags:

views:

239

answers:

2

I need a basic JSON parser that works with J2ME / CLDC 1.1.

A Google search returns tons of answers on this (some even on stackoverflow), but it appears that all point to libraries and solutions that are no longer available (for example, lots point to an implementation that is supposed to be on the json.org site, but at least I can't find anything that isn't J2SE only there).

My best hope so far is the source linked here: https://meapplicationdevelopers.dev.java.net/mobileajax.html, but from that one I can't even find a straight forward way to download the code.

Given the mature state of Java in all other aspects, surely there must be somewhere I can get a pre-compiled JAR to use for parsing JSON from J2ME?

+1  A: 

There is an org.json parser for J2ME but I can't remember the original link. You can get the source code here,

http://grt192.googlecode.com/svn/trunk/CannonBot/src/org/json/me/

ZZ Coder
Thanks, but is it really J2ME compatible? I see no mention of J2ME, and using it in my project results in java.util.HashMap being referenced, which isn't in CLDC as far as I know. Looking closer at the code, it seems to rely on J2SE's collection API quite a lot. Am I missing something?
Liedman
Not familiar with CLDC. If it has Hashtable like MIDP, there is J2ME version of this. I can't find the original site but you can get code here http://grt192.googlecode.com/svn/trunk/CannonBot/src/org/json/me/ and hope it will compile on CLDC.
ZZ Coder
That link was much more what I was hoping for. Even though it isn't compiled, it was easy enough to get the files and build myself. Would you consider posting that link as your answer (or a new answer, if you prefer), I would be happy to upvote/accept it.
Liedman
Ok. Edited my answer.
ZZ Coder
+1  A: 

After getting the accepted answer from ZZ Coder, I downloaded the linked code and built a JAR from it.

So in case you need a compiled JSON serializer/deserializer for J2ME/CLDC, I have posted it on my blog for convenience: http://per.liedman.net/2010/06/07/the-lack-of-a-json-parser-for-j2me/

Liedman