Jackson Tree Model Example – JsonNode

In this Jackson Tree Model Example, we will learn how to convert Java Object to JSON and vice-versa ( JSON to Java object). Jackson Tree Model creates a tree representation of a JSON similar to DOM Tree. Hence it is possible to traverse through each node. Jackson  provides JsonNode API through we will be accessing the individual node using the node name.The readTree and writeTree methods of the Jackson ObjectMapper is used to read and write JSON tree.
[Read more…]

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…]