Skip to main content

TOTD #91: Retrieve JSON libraries using Maven dependency: json-lib

Posted by arungupta on August 7, 2009 at 5:25 AM PDT



So you need to include JSON
libraries in your Maven project. The only option that seems to be
currently available is using href="http://json-lib.sourceforge.net/">json-lib
with the following dependencies:


style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
cellpadding="2" cellspacing="2">
       
<dependency>

           
<groupId>net.sf.json-lib</groupId>

           
<artifactId>json-lib</artifactId>

           
<version>2.3</version>

           
<classifier>jdk15</classifier>

       
</dependency>



The APIs are based upon the original work done at href="http://www.json.org/java">json.org/java.



If you are using NetBeans
for adding the Maven dependency then it nicely shows the different
versions for the artifact as shown below:



alt=""
src="http://blogs.sun.com/arungupta/resource/images/nb67-maven-json-lib-2.3.png">



The usage
guide
and href="http://json-lib.sourceforge.net/snippets.html">samples
at json-lib have lots of documentation to get you started. Don't forget
the package
names are changed so "org.json.JSONObject"
is "net.sf.json.JSONObject" and similarly other classes.



Please leave suggestions on other TOTD (Tip Of The Day) that
you'd like to see.
A complete archive of all the tips is available href="http://blogs.sun.com/arungupta/tags/totd">here.




Technorati: json
maven
json-lib
netbeans

Related Topics >>