(The lack of a) JSON parser for J2ME
07 Jun 2010In a pet project I'm spending my nights working on (hopefully more about that in a later post), I found myself in need of a JSON parser, or deserializer, for J2ME/CLDC. A bit to my surprise, I found that such a thing was not easy to find, even with the whole of the internets at my disposal.
To summarize, it appears that there has been a JSON lib for J2ME up on json.org at some point, but at least I can't find it any longer. Also, some project on java.net is popular to link to, but come on, no download link? No pre-compiled JAR-file?
Anyway, after asking over at stackoverflow.com and getting surprisingly few answers, at least I found a link to some code that was easy enough to grab.
As some kind of attempt to give back to the community, I upload the compiled JAR from that source code here. So if you need to serialize, deserialize, marshal or unmarshal JSON from J2ME/CLDC, grab this JAR and go ahead:
- Compiled JAR: json-me.jar
Source code: json-me.tar.gzUpdated 2010-09-25: the source is now available on BitBucket
The code is most likely a copy of the one that was previously posted on json.org, and is distributed under the json.org license according to the copyright notice in the source (most importantly: "The Software shall be used for Good, not Evil.")
As a very tiny modification, I have added the methods remove and removeAll to the class JSONArray, since I really needed them. I hope you don't mind too much.