In the previous article, we learnt and implemented an example on how to use JAX-RS Restful web service to send & receive XML data as request/response. Here, we will re-use and modify the same example to send & receive JSON data as web service request/response
Jersey is the most popular amongst Restful web service development. Latest Jersey 2.x version has been developed by Oracle/Glassfish team in accordance with JAX-RS 2.0 specification. Earlier Jersey 1.x version was developed and supported by Oracle/Sun team
Latest Jersey release version is 2.12 see here and look documentation and API for details. We will implement Jersey examples in the following articles based on latest 2.x version
JAX-RS specification supports the conversion of Java objects to JSON & vice-versa using Jackson library
Still we need Java objects to send/receive data in JSON format so start designing your XML Schema Definition (XSD), as we can use JAXB Maven plugin to generate Java classes. Later this generated POJO used to exchange JSON data on the fly with the help of Jackson library
Annotation Used
- @Path (ws.rs.Path)
- @GET (ws.rs.GET)
- @POST (ws.rs.POST)
- @PUT (ws.rs.PUT)
- @DELETE (ws.rs.DELETE)
- @PathParam (ws.rs.PathParam)
- @Consumes (ws.rs.Consumes)
- @Produces (ws.rs.Produces)
- MediaType (ws.rs.core.MediaType)
Technology Used
- Java 1.7
- Eclipse Luna IDE
- Jersey-2.12
- Apache Maven 3.2.1
- Apache Tomcat 8.0.54
- Glassfish-4.1
Mavenize or download required jars
Add Jersey-2.12 dependencies to pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | < properties > < jersey.version >2.12</ jersey.version > < jersey.scope >compile</ jersey.scope > < compileSource >1.7</ compileSource > < maven.compiler.target >1.7</ maven.compiler.target > < maven.compiler.source >1.7</ maven.compiler.source > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > </ properties > < dependencies > <!-- Jersey core Servlet 2.x implementation --> < dependency > < groupId >org.glassfish.jersey.containers</ groupId > < artifactId >jersey-container-servlet-core</ artifactId > < version >${jersey.version}</ version > < scope >${jersey.scope}</ scope > </ dependency > <!-- Jersey JSON Jackson (2.x) entity providers support module --> < dependency > < groupId >org.glassfish.jersey.media</ groupId > < artifactId >jersey-media-json-jackson</ artifactId > < version >${jersey.version}</ version > < scope >${jersey.scope}</ scope > </ dependency > </ dependencies > |
Note: Jackson – high performance parser is included as dependencies for JSON support
Folks who aren’t familiar with Maven concepts or don’t require maven for their project, can download the below jars individually from the central repository or maven repository and include them in the classpath
- jersey-container-servlet-core
- javax.ws.rs-api-2.0.1
- jersey-server-2.12
- jersey-common-2.12
- jersey-client-2.12
- jersey-guava-2.12
- javax-annotation-api-1.2
- javax.inject-2.3.0-b10
- hk2-api-2.3.0-b10
- hk2-utils-2.3.0-b10
- aop-alliance-repackaged-2.3.0-b10
- hk2-locator
- javassist-3.18.1-GA
- validation-api-1.1.0.Final
- osgi-resource-locator-1.0.1
- jersey-media-json-jackson
- jackson-jaxrs-base-2.3.2
- jackson-core-2.3.2
- jackson-databind-2.3.2
- jackson-jaxb-json-provider-2.3.2
- jackson-annotation-2.3.2
- jackson-module-jaxb-annotation-2.3.2
JAXB – Generating java source files from XSD
Steps to generate java-sources from XML Schema Definition (XSD)
- configure JAXB Maven plugin in pom.xml
- write well-defined XSD for your service
- use maven command “mvn generate-sources” to generate java source files
Configure JAXB Maven plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <!-- JAXB plugin to generate-sources from XSD --> < plugin > < groupId >org.codehaus.mojo</ groupId > < artifactId >jaxb2-maven-plugin</ artifactId > < version >1.6</ version > < executions > < execution > < goals > < goal >xjc</ goal > <!-- xjc/generate --> </ goals > < configuration > < outputDirectory >${basedir}/generated/java/source</ outputDirectory > < schemaDirectory >${basedir}/src/main/resources/com/jersey/series/json/service/entities</ schemaDirectory > < schemaFiles >*.xsd</ schemaFiles > < schemaLanguage >XMLSCHEMA</ schemaLanguage > < extension >true</ extension > < args > < arg >-XtoString</ arg > </ args > < plugins > < plugin > < groupId >org.jvnet.jaxb2_commons</ groupId > < artifactId >jaxb2-basics</ artifactId > < version >0.6.4</ version > </ plugin > </ plugins > </ configuration > </ execution > </ executions > </ plugin > |
Book.xsd
Below XSD contains two elements with name “BookType” and “BookListType”
- BookType contains four attributes namely bookId, bookName, author, category
- BookListType which returns list of BookType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <? xml version = "1.0" encoding = "UTF-8" ?> elementFormDefault = "qualified" > <!-- book object with four attributes --> < xsd:element name = "BookType" > < xsd:complexType > < xsd:sequence > < xsd:element name = "bookId" type = "xsd:int" /> < xsd:element name = "bookName" type = "xsd:string" /> < xsd:element name = "author" type = "xsd:string" /> < xsd:element name = "category" type = "xsd:string" /> </ xsd:sequence > </ xsd:complexType > </ xsd:element > <!-- an object to contain lists of books referencing above Book object --> < xsd:element name = "BookListType" > < xsd:complexType > < xsd:sequence > < xsd:element ref = "tns:BookType" minOccurs = "0" maxOccurs = "unbounded" /> </ xsd:sequence > </ xsd:complexType > </ xsd:element > </ xsd:schema > |
Run mvn generate-sources
Look at the generated java source files in the generated folder
BookType.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | package in.benchresources.cdm.book; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType (XmlAccessType.FIELD) @XmlType (name = "" , propOrder = { "bookId" , "bookName" , "author" , "category" }) @XmlRootElement (name = "BookType" ) public class BookType { protected int bookId; @XmlElement (required = true ) protected String bookName; @XmlElement (required = true ) protected String author; @XmlElement (required = true ) protected String category; public int getBookId() { return bookId; } public void setBookId( int value) { this .bookId = value; } public String getBookName() { return bookName; } public void setBookName(String value) { this .bookName = value; } public String getAuthor() { return author; } public void setAuthor(String value) { this .author = value; } public String getCategory() { return category; } public void setCategory(String value) { this .category = value; } } |
BookListType.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | package in.benchresources.cdm.book; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType (XmlAccessType.FIELD) @XmlType (name = "" , propOrder = { "bookType" }) @XmlRootElement (name = "BookListType" ) public class BookListType { @XmlElement (name = "BookType" ) protected List<BookType> bookType; public List<BookType> getBookType() { if (bookType == null ) { bookType = new ArrayList<BookType>(); } return this .bookType; } } |
Directory Structure
Before moving on, let us understand the directory/package structure once you create project in Eclipse IDE
Maven has to follow certain directory structure
- src/test/java –> test related files, mostly JUnit test cases
- src/main/java –> create java source files under this folder
- src/main/resources –> all configuration files placed here
- src/test/resources –> all test related configuration files placed here
- Maven Dependencies or Referenced Libraries –> includes jars in the classpath
- WEB-INF under webapp –> stores web.xml & other configuration files related to web application
Project Structure (Package Explorer view in Eclipse)
Jars Libraries Used in the Project (Maven Dependencies)
Web application
For any web application, entry point is web.xml which describes how the incoming http requests are served / processed. Further, it describes about the global-context and local-context param (i.e.; <context-param> & <init-param>) for loading files particular to project requirements & contains respective listener
With this introduction, we will understand how we configured web.xml for Jersey JAX-RS Restful web service
web.xml (the entry point –> under WEB-INF)
This web.xml file describes,
- Like any JEE web framework register “org.glassfish.jersey.servlet.ServletContainer” with servlet container
- http requests with URL pattern “/rest/*” will be sent to the registered servlet called “jersey-servlet” i.e.; (org.glassfish.jersey.servlet.ServletContainer)
- Set <init-param> with <param-name> as “jersey.config.server.provider.packages” and <param-value> describing the qualified package name of the JAX-RS annotated Resource/Provider classes. In this example, “com.jersey.series.json.service”
- <welcome-file-list> files under this tag is the start-up page
web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" > < display-name >Jersey-JSON-IO</ display-name > <!-- Jersey Servlet --> < servlet > < servlet-name >jersey-servlet</ servlet-name > < servlet-class >org.glassfish.jersey.servlet.ServletContainer</ servlet-class > <!-- Register resources and providers --> < init-param > < param-name >jersey.config.server.provider.packages</ param-name > < param-value >com.jersey.series.json.service</ param-value > </ init-param > < load-on-startup >1</ load-on-startup > </ servlet > < servlet-mapping > < servlet-name >jersey-servlet</ servlet-name > < url-pattern >/rest/*</ url-pattern > </ servlet-mapping > <!-- welcome file --> < welcome-file-list > < welcome-file >index.html</ welcome-file > </ welcome-file-list > </ web-app > |
Let’s see coding in action
URL Pattern
Http url for any common web application is http://<server>:<port>/<root-context>/<from_here_application_specific_path>
In our example, we are going to deploy the war into Tomcat 8.0 server so our server and port are localhost and 8080 respectively. Context root is the project name i.e.; Jersey-JSON-IO. Initial path for this application is http://localhost:8080/Jersey-JSON-IO
We have configured “/rest/*” as url-pattern for the “jersey-servlet” servlet in web.xml and at class-level path configured is “/bookservice” using @Path annotation. Next respective path for each method annotated with @Path (method-level)
Book Service interface
Defines basic CRUD operations for Book Service
NOTE: It’s always a good programming practice to do code-to-interface and have its implementation separately
IBookService.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package com.jersey.series.json.service; import in.benchresources.cdm.book.BookListType; import in.benchresources.cdm.book.BookType; public interface IBookService { // Basic CRUD operations for Book Service public String createOrSaveBookInfo(BookType bookType); public BookType getBookInfo( int bookId); public String updateBookInfo(BookType bookType); public String deleteBookInfo( int bookId); public BookListType getAllBookInfo(); } |
Book Service implementation
Implements above interface
Defines simple CURD operations
- @POST – create/inserts a new resource (adds new book information)
- @GET – read/selects internal resource representation based on the bookId
- @PUT – update/modifies an internal resource representation (modify book)
- @DELETE – delete/removes a resource (delete book)
- @GET – retrieves all books (get all books information)
Let’s discuss @Produces, @Consumes and MediaType
@Consumes
Defines which MIME type is consumed by this method. For this example, exposed methods are restricted to consume only JSON data and it is annotated with @Consumes(MediaType.APPLICATION_JSON)
@Produces
Defines which MIME type it will produce. For this example, exposed methods are restricted to produce only JSON data and it is annotated with @Produces(MediaType.APPLICATION_JSON)
Most widely used Media Types are
- APPLICATION_XML,
- APPLICATION_JSON,
- TEXT_PLAIN,
- TEXT_XML,
- APPLICATION_FORM_URLENCODED,
- etc
Note: Jersey doesn’t inherit JAX-RS annotations. So we are annotating Resource/Provider classes and then defining qualified package name in web.xml
BookServiceImpl.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | package com.jersey.series.json.service; import in.benchresources.cdm.book.BookListType; import in.benchresources.cdm.book.BookType; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path ( "/bookservice" ) public class BookServiceImpl implements IBookService { // Basic CRUD operations for Book Service @POST @Path ( "addbook" ) @Consumes (MediaType.APPLICATION_JSON) @Produces (MediaType.APPLICATION_FORM_URLENCODED) public String createOrSaveBookInfo(BookType bookType) { // get book information from formal arguments and inserts into database & return bookId (primary_key) return "New Book information saved successfully with Book_ID " + bookType.getBookId(); } @GET @Path ( "getbook/{id}" ) @Consumes (MediaType.APPLICATION_FORM_URLENCODED) @Produces (MediaType.APPLICATION_JSON) public BookType getBookInfo( @PathParam ( "id" ) int bookId) { // retrieve book information based on the id supplied in the formal argument BookType bookType = new BookType(); bookType.setBookId(bookId); bookType.setBookName( "Molecular Biology of The Gene" ); bookType.setAuthor( "James D Watson" ); bookType.setCategory( "Microbiology" ); return bookType; } @PUT @Path ( "updatebook" ) @Consumes (MediaType.APPLICATION_JSON) @Produces (MediaType.APPLICATION_FORM_URLENCODED) public String updateBookInfo(BookType bookType) { // update book info & return SUCCESS message return "Book information updated successfully" ; } @DELETE @Path ( "deletebook/{id}" ) @Consumes (MediaType.APPLICATION_FORM_URLENCODED) @Produces (MediaType.APPLICATION_FORM_URLENCODED) public String deleteBookInfo( @PathParam ( "id" ) int bookId) { // delete book info & return SUCCESS message return "Book information with Book_ID " + bookId + " deleted successfully" ; } @GET @Path ( "getallbook" ) @Consumes (MediaType.APPLICATION_FORM_URLENCODED) @Produces (MediaType.APPLICATION_JSON) public BookListType getAllBookInfo() { // create a object of type BookListType which takes book objects in its list BookListType bookListType = new BookListType(); BookType bookOne = new BookType(); bookOne.setBookId( 10002 ); bookOne.setBookName( "Cellular and Molecular Immunology" ); bookOne.setAuthor( "Abul K. Abbas" ); bookOne.setCategory( "Immunology" ); bookListType.getBookType().add(bookOne); // add to bookListType BookType bookTwo = new BookType(); bookTwo.setBookId( 10003 ); bookTwo.setBookName( "Medical Physiology" ); bookTwo.setAuthor( "Walter F. Boron" ); bookTwo.setCategory( "Physiology" ); bookListType.getBookType().add(bookTwo); // add to bookListType return bookListType; } } |
Tomcat-8.0.12 Deployment
- Run maven command to build the war: mvn clean install (use command prompt or integrated maven in eclipse IDE
- Copy(ctrl+c) the war file from the target folder
- Paste(ctrl+v) it into apache tomcat (webapps folder)
- Start the tomcat server
Glassfish-4.1 Deployment
- Run maven command to build the war: mvn clean install (use command prompt or integrated maven in eclipse IDE
- Once you see “BUILD SUCCESS” after running maven command, keep the war file ready to be deployed
- There are two ways to deploy war file into Glassfish-4.1
- Online
- Offline
- Click here to understand above deployments process in detail
Test the service !!
Testing
There are many ways to do testing
- Access html page from web browser
- Copy the URL of GET service into web browser
- Advanced REST client from Google Chrome
- Rest client in Mozilla Firefox Add On
- Write your own client for example, Java client using improved CloseableHttpClient from Apache
- JDK’s in-built classes like HttpURLConnection
- Using Client, WebTarget from core JAX-RS classes javax.ws.rs.client
1. Using RestClient from Mozilla Firefox Add-On
First service: @POST (createOrSaveBookInfo())
URL: http://localhost:8080/Jersey-JSON-IO/rest/bookservice/addbook
Request:
1 2 3 4 5 6 | { "bookId": 10001, "bookName": "Molecular Biology of The Gene", "author": "James D Watson", "category": "Microbiology" } |
Content-Type: application/json
Accept: application/x-www-form-urlencoded
Response: New Book information saved successfully with Book_ID 10001
Second service: @GET (getBookInfo())
URL: http://localhost:8080/Jersey-JSON-IO/rest/bookservice/getbook/10001
Request: None
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Response:
1 2 3 4 5 6 | { "bookId": 10001, "bookName": "Molecular Biology of The Gene", "author": "James D Watson", "category": "Microbiology" } |
Third service: @PUT (updateBookInfo())
URL: http://localhost:8080/Jersey-JSON-IO/rest/bookservice/updatebook
Request:
1 2 3 4 5 6 | { "bookId": 10001, "bookName": "Molecular Biology of The Gene", "author": "James D Watson", "category": "Microbiology" } |
Content-Type: application/json
Accept: application/x-www-form-urlencoded
Response: Book information updated successfully
Fourth service: @DELETE (deleteBookInfo())
URL: http://localhost:8080/Jersey-JSON-IO/rest/bookservice/deletebook/10002
Request: None
Content-Type: application/x-www-form-urlencoded
Accept: application/x-www-form-urlencoded
Response: Book information with Book_ID 10002 deleted successfully
Fifth service: @GET (getAllBookInfo())
URL: http://localhost:8080/Jersey-JSON-IO/rest/bookservice/getallbook
Request: None
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | { "BookType": [ { "bookId": 10002, "bookName": "Cellular and Molecular Immunology", "author": "Abul K. Abbas", "category": "Immunology" }, { "bookId": 10003, "bookName": "Medical Physiology", "author": "Walter F. Boron", "category": "Physiology" } ] } |
2. Java client
Uses Client, ClientBuilder, WebTarget and Response classes from core JAX-RS package javax.ws.rs.client for invoking Restful web service
Note: Commented lines will help out us to try (set) various http request header parameters
TestBookService.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | package test.jersey.series.json.service; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.Invocation.Builder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; public class TestBookService { public static void main(String[] args) { // setting & invoking first service getBook/10001 System.out.println( "Invoking and executing getBook service for book id 10001" ); String responseStringGet = testBookServiceForGetRequest(httpGetURL); System.out.println( "GET >> Response String : " + responseStringGet); // setting & invoking second service addBook with XML request System.out.println( "\n\nInvoking and executing addBook service with request XML" ); String requestString = "{" + " \"bookId\": 10005, " + " \"bookName\": \"Food Microbiology\"," + " \"author\": \"Martin Ray Adams\"," + " \"category\": \"Microbiology\"" + "}" ; String responseStringPost = testBookServiceForPostRequest(httpPostURL, requestString); System.out.println( "POST >> Response String : " + responseStringPost); } /** * * @param httpURL * @return */ public static String testBookServiceForGetRequest(String httpURL){ // local variables ClientConfig clientConfig = null ; Client client = null ; WebTarget webTarget = null ; Invocation.Builder invocationBuilder = null ; Response response = null ; int responseCode; String responseMessageFromServer = null ; String responseString = null ; try { // invoke service after setting necessary parameters clientConfig = new ClientConfig(); client = ClientBuilder.newClient(clientConfig); // client.property("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); // client.property("accept", MediaType.APPLICATION_JSON); webTarget = client.target(httpURL); // invoke service invocationBuilder = webTarget.request(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON); // invocationBuilder.header("some-header", "header-value"); response = invocationBuilder.get(); // get response code responseCode = response.getStatus(); System.out.println( "Response code: " + responseCode); if (response.getStatus() != 200 ) { throw new RuntimeException( "Failed with HTTP error code : " + responseCode); } // get response message responseMessageFromServer = response.getStatusInfo().getReasonPhrase(); System.out.println( "ResponseMessageFromServer: " + responseMessageFromServer); // get response string responseString = response.readEntity(String. class ); } catch (Exception ex) { ex.printStackTrace(); } finally { // release resources, if any response.close(); client.close(); } return responseString; } /** * * @param httpURL * @param requestString * @return */ public static String testBookServiceForPostRequest(String httpURL, String requestString) { // local variables ClientConfig clientConfig = null ; Client client = null ; WebTarget webTarget = null ; Builder builder = null ; Response response = null ; int responseCode; String responseMessageFromServer = null ; String responseString = null ; try { // invoke service after setting necessary parameters clientConfig = new ClientConfig(); client = ClientBuilder.newClient(clientConfig); // client.property("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); // client.property("accept", MediaType.APPLICATION_JSON); webTarget = client.target(httpURL); // invoke service builder = webTarget.request(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_JSON); response = builder.post(Entity.entity(requestString, MediaType.APPLICATION_JSON)); // get response code responseCode = response.getStatus(); System.out.println( "Response code: " + responseCode); if (response.getStatus() != 200 ) { throw new RuntimeException( "Failed with HTTP error code : " + responseCode); } // get response message responseMessageFromServer = response.getStatusInfo().getReasonPhrase(); System.out.println( "ResponseMessageFromServer: " + responseMessageFromServer); // get response string responseString = response.readEntity(String. class ); } catch (Exception ex) { ex.printStackTrace(); } finally { // release resources, if any response.close(); client.close(); } return responseString; } } |
Output in console
Invoking and executing getBook service for book id 10001 Response code: 200 ResponseMessageFromServer: OK GET >> Response String : {"bookId":10001,"bookName":"Molecular Biology of The Gene","author":"James D Watson","category":"Microbiology"} Invoking and executing addBook service with request XML Response code: 200 ResponseMessageFromServer: OK POST >> Response String : New Book information saved successfully with Book_ID 10005
Conclusion: Thus, JSON format can be used to send/receive data where performance is a big consideration as it is light-weight. Especially, in mobile development client prefer to use JSON data for web service interaction
Download project
Jersey-2x-JSON-IO (12kB)
Happy Coding !!
Happy Learning !!