 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Differences between org.simple.json and org.json libraries in Java?
In Java, org.simple.json and org.json are two libraries that help in reading, writing, and manipulating JSON. But still, they are different. In this article, we are going to learn about these differences.
Difference between JSON.simple vs JSON
Let's see the below differences and they are -
| Features | JSON.simple | JSON | 
|---|---|---|
| Purpose | Read and write JSON data in Java (encode and decode JSON objects). | Parse JSON. | 
| Conversion | JSON operations only. | Converts between JSON and XML, HTTP headers, Cookies, and CDF. | 
| Key Classes | JSONValue, JSONObject, JSONArray, JsonString, JsonNumber. | JSONObject, JSONTokener, JSONWriter, JSONArray, CDL, Cookie, CookieList. | 
| Required Jar | json.simple.jar to execute the JSON program file. | json.jar to execute the JSON program file. | 
Example for org.simple.json package
In the given program, it creates a JSONObject, adds key-value pairs, and gives output, JSON as a string using the toJSONString() method.
import org.json.simple.JSONObject; public class SimpleJsonTest { public static void main(String[] args) { JSONObject jsonObj = new JSONObject(); jsonObj.put("empName", "Raja"); jsonObj.put("employeeId", "115"); jsonObj.put("age","30"); System.out.println(jsonObj.toJSONString()); } } Following is the output of the above program -
{"empName":"Raja","employeeId":"115","age":"30"}  Example for org.json package
Following example prints the contents of a JSON document using the org.json library -
import org.json.*; public class JSONTest { public static void main(String args[]) throws JSONException { String json = "{" + ""Name": "Jai"," + ""Age": 25, " + ""Salary": 25000.00 " + "}"; JSONObject jsonObj = new JSONObject(json); System.out.println(jsonObj.toString()); } } Following is the output of the above program -
{"Name":"Jai","Age":25,"Salary":25000}Advertisements
 