Newsletter |
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(); jo.put("site","java4s.com"); jo.put("content","Java"); jo.put("TotalLinks",927); System.out.println(jo); } }
Key(s):
- 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 🙂
 Output
​ ​​
You Might Also Like
::. About the Author .:: | ||
Comments
11 Responses to “Using JSONObject In Java Programs”
Hai Team members of java4s.com ,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
@Ramanujam
You bet, Glad to hear such a feedback 🙂
Thank you.
https://www.java4s.com such an excellent site for the java biginers….thank u soooooooo much
How can we add multiple records to JSON Object?
I have ever seen such a simple tutorial like Java4s…:)
Can u show a demo of jquery easyui datagrid with jsp /servlet where it returns json object.
How to iterate json object
Thanks
Amazing! work compare with others… cheers…
Sir please upload more and more examples of JSON for web development examples…Thanks alot
Hi SIVATEJA founder of java4s please provide database queries also while doing hibernate and Spring Boot tutorials to create tables and do CRUD operations.