How to write JSON object to File in Java?

In my previous article we have learnt How to read JSON file in Java, now let’s see how we can write JSON Object to File in Java. Here also we will be using the JSON.simple library download the json-simple-1.1.1.jar (or) if you are running on maven add the below dependency to your pom.xml

 <dependency>
   <groupId>com.googlecode.json-simple</groupId>
   <artifactId>json-simple</artifactId>
   <version>1.1.1</version>
</dependency>

[Read more…]

How to read JSON file in Java – JSONObject and JSONArray

What is JSON ?

JSON stands for JavaScript Object Notation. JSON is one of the widely used data-interchange format as it is a lightweight data-interchange format and language independent and it started to slowly replace the XML format. In this tutorial, we will see  how to use JSON.simple to read JSON file. We will be using JSONObject and JSONArray to perform the JSON read operation. [Read more…]