Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Visitor
Posts: 1
Registered: ‎04-11-2010
My Device: Blackberry 8820
My Carrier: AT&T

JSON .jar

I scoured the internet for HOURS today trying to find the J2ME JSON class to import into the JDE. I never found it, but I DID find a copy of the source (which is no longer on the main JSON page for some reason), and compiled it to a jar. It worked like a charm for me, and thought that others might find it useful.

 

Link: http://www.megaupload.com/?d=JFV1H0AU

 

Enjoy!

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: JSON .jar

Very good, should be helpful to many.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Contributor
Posts: 7
Registered: ‎06-30-2010
My Device: Storm 9500
My Carrier: Vodafone

Re: JSON .jar

[ Edited ]

Can you please send me the jar file through my email.

I have used your link and different other links.

 

I get a nagging error when i import the json.jar Smiley Sad

 

Please if you can, I would be very thnakful to you.

 

xxxxxx@xxxxxxxx.com.

 

Thanks again.

 

EDIT: Personal Information Removed - Info such as E-mails are prohibited for security purposes

New Contributor
Posts: 3
Registered: ‎04-19-2010
My Device: 9700
My Carrier: Dev

Re: JSON .jar

It's very very very useful for me.

Developer
Posts: 105
Registered: ‎05-22-2008
My Device: Not Specified

Re: JSON .jar

Hi

 

Is the source code for this available anywhere ?

 

Without javadocs, cant do much with it...

 

Thanks

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: JSON .jar

New Developer
New Developer
Posts: 151
Registered: ‎01-05-2010
My Device: dev alpha c (bb10)
My Carrier: www.rzr.online.fr

Re: JSON .jar

[ Edited ]

can you also share the project and how you build it to support os 4.5+?

 

because it failed my side using JDE 4

 


Building example

C:\Program Files (x86)\Research In Motion\BlackBerry JDE 4.5.0\bin\rapc.exe  -quiet  import="C:\Program Files (x86)\Research In Motion\BlackBerry JDE 4.5.0\lib\net_rim_api.jar";lib\${PROJECT}.jar;lib\json.jar codename=example\example example\example.rapc warnkey=0x52424200;0x52525400;0x52435200 Y:\src\${PROJECT}-java.git\example\src\mypackage\MyApp.java Y:\src\${PROJECT}-java.git\example\src\mypackage\MyScreen.java
lib\json.jar(json.cod): Warning!: Import file is marked non-parseable

 

 

 

 

related :

 

http://stackoverflow.com/questions/1470406/how-to-parse-the-json-response-in-blackberry-j2me/5500211...

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: JSON .jar

Can't answer for Eclipse, but in JDE, you can create a directory structure for the JSON files that matches the application, update the package name similarly (so that the JSON package doesn't clash with anyone else's JSON or the built-in JSON in OS 6) and add the source files.  So JSON gets included in the application rather than being a separate jar or cod. 

 

Does that help?

New Developer
New Developer
Posts: 151
Registered: ‎01-05-2010
My Device: dev alpha c (bb10)
My Carrier: www.rzr.online.fr

Re: JSON .jar

[ Edited ]

I am confused (as you have noticed on other threads)

 

 

why should those classes clash ?

 

In the final application there should be only one json code and located in official package Smiley Happy

 

To make it clear i am trying to make a lib that can work on org.json.me.JSONObject (not fake.hack.JSONObject ) ...

 

 

now i try to link them using BlackBerry_JDE_4.6.1.exe

because later ones are said to be broken :

http://supportforums.blackberry.com/t5/Java-Development/Problem-importing-JAR-to-my-application/m-p/...

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: JSON .jar

Now I'm confused....

 

Let us review where I'm coming from. 

 

I can't help with the problem of getting a jar into a cod, I've never done that.  I do use jars in by builds for application Libraries, but in all cases I have built the associated cods, I just use the jars to provide separation between the Libraries.  If this doesn't make sense to you, don't worry, it doesn't make much sense to me either.  The point here is that I always (till now anyway) build from source.

 

Now one of the source 'libraries' I use is Json.  And I use it on pre OS 6.0 applications.  So I can't rely on the one built-in to OS 6.0.

 

In addition, I don't want my users to have to download two cods, one of which contains Json.  So I build it into the application.  Json is quite small - I think the compiled classes total about 40K,  So having it twice on the device doesn't bother me.

 

But this has potential to cause a problem.  The BlackBerry OS will only (as far as I know) load only one version of a class.  A class is defined by its full package and class name.  Now I don't want my application broken by someone else's implementation of the Json classes, which I haven't tested (yes I know it should work but...).  So I change the package name for my Json as described.  And include it with the application. 

 

This process works for Json, especially, as I noted, because it is quite small.  Perhaps it will work for you too.