Using JSONObject In Java Programs

Json » on Feb 1, 2012 { 11 Comments } By Sivateja

Let us see how to use JSONObject in java program, files required..

Jars required to JSON in java program..

  • json-lib-2.2.2-jdk15.jar
  • ezmorph.jar
  • commons-lang.jar
  • commons-logging.jar
  • commons-beanutils.jar
  • ommons-collections.jar

you can download these jars from previous session

import net.sf.json.JSONObject;
public class JsonEx {

	public static void main(String args[])
		JSONObject jo=new JSONObject();



  • Make sure you must have all above jar files in your class path
  • Our java program must import net.sf.json.* package

Am not giving any example program for using JSONObject in servlets and using JSONObject in jsp, as its the same logic. Even in the struts too 🙂


​ ​​

You Might Also Like

  ::. About the Author .::

Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


11 Responses to “Using JSONObject In Java Programs”
  1. Ramanujam says:

    Hai Team members of ,the content which is available in this site which is very useful and also much interesting to learn any topic from initial level. Tank you very much

  2. Java4s says:


    You bet, Glad to hear such a feedback 🙂
    Thank you.

  3. such an excellent site for the java biginers….thank u soooooooo much

  4. How can we add multiple records to JSON Object?

  5. break says:

    I have ever seen such a simple tutorial like Java4s…:)

  6. Joshua says:

    Can u show a demo of jquery easyui datagrid with jsp /servlet where it returns json object.

  7. fareed says:

    How to iterate json object

  8. Amazing! work compare with others… cheers…

  9. amarnath says:

    Sir please upload more and more examples of JSON for web development examples…Thanks alot

  10. raja says:

    Hi SIVATEJA founder of java4s please provide database queries also while doing hibernate and Spring Boot tutorials to create tables and do CRUD operations.


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.