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> … [Read more...]
How to Convert Java Object to JSON using JAXB
In this example we will see how we can convert a Java Object into an JSON using JAXB Marshalling Technique. JAXB Dependency We will be requiring the below jars to be put in the classpath for performing the marshalling operation. jaxb-api.jar org.eclipse.persistence.moxy-2.6.2.jar eclipselink-2.6.2.jar validation-api-1.1.0.Final.jar … [Read more...]
JAX-RS REST @Consumes both XML and JSON Example
Previously we have learnt how to use @Produces annotation, Consuming JSON or Consuming XML separately. We have consumed either xml or json request but not both xml and json in a single method. In this example we will learn how to consume multiple media type which the client is giving as input, lets see how we can achieve it. … [Read more...]
JAX-RS REST @Produces both XML and JSON Example
In my previous article we have learnt how to use @Produces annotation. We have produced either xml or json response but not able to produce both xml and json in a single method. In this example we will learn how to produce multiple media type response depending upon the clients request we will produce response, lets see how we can achieve it. … [Read more...]