{"id":299,"date":"2010-07-12T23:02:00","date_gmt":"2010-07-12T23:02:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/add-json-capabilities-into-your-gwt-application.html"},"modified":"2012-10-21T19:16:54","modified_gmt":"2012-10-21T19:16:54","slug":"add-json-gwt-application","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html","title":{"rendered":"Add JSON capabilities into your GWT application"},"content":{"rendered":"<p><span style=\"font-weight: bold\">Introduction to JSON<\/span><br \/>\nWhile working on web applications, the issue of client-server data exchange always arises. There are various approaches on this matter, with a lot of them using XML for the exchange. A not so well known format for performing this task is JSON. <a href=\"http:\/\/www.json.org\/\">JSON (JavaScript Object Notation)<\/a> is a lightweight data-interchange format. It is easy for humans to read and write, and easy for machines to parse and generate. JSON is considered less verbose and bloated than XML and more readable, even though those might vary on the transmitted data. There are multiple resources online to <a href=\"http:\/\/www.hunlock.com\/blogs\/Mastering_JSON_%28_JavaScript_Object_Notation_%29\">kick start you with JSON<\/a>.<\/p>\n<p><span style=\"font-weight: bold\">JSON libraries<\/span><br \/>\nJSON is a text format that is completely language independent and there are libraries available for a huge number of programming languages. For <a href=\"http:\/\/www.json.org\/java\/\">JSON in Java<\/a>, the source code of the implementation is available. Note that the site does not provide binaries in an archive file, but we have compiled the classes and bundled them in a JAR file, which you can directly download <a href=\"http:\/\/dl.dropbox.com\/u\/7215751\/JavaCodeGeeks\/JsonGWTTutorial\/JSON-lib\/json.jar\">here<\/a>.<\/p>\n<p><span style=\"font-weight: bold\">GWT and JSON integration<\/span><br \/>\nIn this tutorial, I am going to show you how to manipulate JSON in GWT so that you can communicate with a JSON enabled web application. Note that in GWT applications, the most common way to achieve <a href=\"http:\/\/code.google.com\/webtoolkit\/doc\/latest\/DevGuideServerCommunication.html\">client-server communication<\/a> is via <a href=\"http:\/\/code.google.com\/webtoolkit\/doc\/latest\/DevGuideServerCommunication.html#DevGuideRemoteProcedureCalls\">RPC calls<\/a>. So using JSON applies mostly in the case when an external server is reached via plain old HTTP calls.<\/p>\n<p><span style=\"font-weight: bold\">Creating the application<\/span><br \/>\nLet&#8217;s get started by creating a new Eclipse project (\u201cFile ? New ? Web Application Project\u201d) and name it \u201cJsonGwtProject\u201d. Select support only for Google&#8217;s Web Toolkit and not for the App Engine. The role of the server will be played by the embedded Jetty container that is provided by the GWT SDK.<\/p>\n<p><a href=\"http:\/\/1.bp.blogspot.com\/_piNjpdpJZXA\/TCdQ7TMmXZI\/AAAAAAAAAFI\/JQ0TeFH71j0\/s1600\/01-new-web-project.png\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/1.bp.blogspot.com\/_piNjpdpJZXA\/TCdQ7TMmXZI\/AAAAAAAAAFI\/JQ0TeFH71j0\/s320\/01-new-web-project.png\" style=\"cursor: pointer;height: 278px;margin: 0px auto 10px;text-align: center;width: 320px\" \/><\/a><\/p>\n<p>After the project skeleton is created, edit the modules declaration file (named \u201cJsonGwtProject.gwt.xml\u201d in our case). Add the following line after the line that reads \u201cOther modules inherits\u201d in order to make your GWT application JSON enabled.<\/p>\n<pre class=\"brush:xml\">&lt;inherits name=\"com.google.gwt.json.JSON\" \/&gt;\r\n<\/pre>\n<p><span style=\"font-weight: bold\">The domain model object<\/span><br \/>\nNow, let&#8217;s create the model object that will be used to hold the data. Our model is a \u201cProduct\u201d class with various fields:<\/p>\n<ul>\n<li>Name<\/li>\n<li>Company<\/li>\n<li>Serial Number<\/li>\n<li>Prices<\/li>\n<\/ul>\n<p>Multiple prices will be used in order to show you how to use nested JSON expressions.<\/p>\n<p>The corresponding Java class (plain old Java object) is the following:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.json.gwt.server.model;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.List;\r\n\r\npublic class Product {\r\n \r\n private String name;\r\n private String company;\r\n private String serialNumber;\r\n private List&lt;Double&gt; prices = new LinkedList&lt;Double&gt;();\r\n \r\n public Product(String name, String company, String serialNumber, List&lt;Double&gt; prices) {\r\n  super();\r\n  this.name = name;\r\n  this.company = company;\r\n  this.serialNumber = serialNumber;\r\n  this.prices = prices;\r\n }\r\n \r\n public String getName() {\r\n  return name;\r\n }\r\n public void setName(String name) {\r\n  this.name = name;\r\n }\r\n public String getCompany() {\r\n  return company;\r\n }\r\n public void setCompany(String company) {\r\n  this.company = company;\r\n }\r\n public String getSerialNumber() {\r\n  return serialNumber;\r\n }\r\n public void setSerialNumber(String serialNumber) {\r\n  this.serialNumber = serialNumber;\r\n }\r\n public List&lt;Double&gt; getPrices() {\r\n  return prices;\r\n }\r\n public void setPrices(List&lt;Double&gt; prices) {\r\n  this.prices = prices;\r\n }\r\n\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: bold\">Application&#8217;s server side<\/span><br \/>\nNow let&#8217;s create the server side code of the application. We will create a servlet that will be used to simulate an external server from which the data will be retrieved. The servlet creates a JSON response to the client using a static list of products (in a real-life application, the products would be fetched from a DAO or even better from an other service). Make sure you include the json.jar you downloaded into your project&#8217;s classpath and that it is also copied in the \u201cwar\\WEB-INF\\lib\u201d folder. The servlet code is the following:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.json.gwt.server;\r\n\r\nimport java.io.IOException;\r\nimport java.io.PrintWriter;\r\nimport java.util.Arrays;\r\nimport java.util.LinkedList;\r\nimport java.util.List;\r\n\r\nimport javax.servlet.ServletException;\r\nimport javax.servlet.http.HttpServlet;\r\nimport javax.servlet.http.HttpServletRequest;\r\nimport javax.servlet.http.HttpServletResponse;\r\n\r\nimport org.json.JSONObject;\r\n\r\nimport com.javacodegeeks.json.gwt.server.model.Product;\r\n\r\npublic class ProductsServlet extends HttpServlet {\r\n \r\n private static final long serialVersionUID = 8032611514671727168L;\r\n \r\n private static List&lt;Product&gt; products = new LinkedList&lt;Product&gt;();\r\n \r\n static {\r\n  Product product1 = new Product(\"Prod1\", \"Company1\", \"12345\", Arrays.asList(123.2, 123.6));\r\n  Product product2 = new Product(\"Prod2\", \"Company2\", \"67890\", Arrays.asList(234.2, 234.6));\r\n  products.add(product1);\r\n  products.add(product2);\r\n }\r\n\r\n @Override\r\n protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\r\n  \r\n  try {\r\n   \r\n   JSONObject responseObj = new JSONObject();\r\n   \r\n   List&lt;JSONObject&gt; productObjects = new LinkedList&lt;JSONObject&gt;();\r\n   \r\n   for (Product product : products) {\r\n    \r\n    JSONObject productObj = new JSONObject();\r\n    \r\n    productObj.put(\"name\", product.getName());\r\n    productObj.put(\"company\", product.getCompany());\r\n    productObj.put(\"serialNumber\", product.getSerialNumber());\r\n    \r\n    List&lt;JSONObject&gt; pricesObjects = new LinkedList&lt;JSONObject&gt;();\r\n    for (Double price : product.getPrices()) {\r\n     JSONObject priceObj = new JSONObject();\r\n     priceObj.put(\"price\", price);\r\n     pricesObjects.add(priceObj);\r\n    }\r\n    \r\n    productObj.put(\"prices\", pricesObjects);\r\n    \r\n    productObjects.add(productObj);\r\n   }\r\n   \r\n   responseObj.put(\"products\", productObjects);\r\n   \r\n   PrintWriter writer = resp.getWriter();\r\n   writer.write(responseObj.toString());\r\n   writer.flush();\r\n   \r\n  } \r\n  catch (Exception e) {   \r\n   e.printStackTrace();\r\n   throw new ServletException(e);\r\n  }\r\n  \r\n }\r\n \r\n}\r\n<\/pre>\n<p><span style=\"font-weight: bold\">Java JSON response generation<\/span><br \/>\nLet me explain how the JSON response is produced. Make sure you are importing the JSON classes from the org.json package and not the com.google.gwt.json. The first step is to create a JSONObject which will be the one that will hold the response. Since we most probably have a number of products, we also create a List of JSONObjects. We loop through the existing products and create a separate object for each one of them. In that object, we add key-value pairs, just like we would do with a Map. For the prices, we also create a List of JSONObjects and then we add the whole list in the product&#8217;s JSONObject. Finally we add the List of product objects into the response&#8217;s JSONObject. The toString() method of the JSONObject is used to create the string representation. For that example, the result is:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>{&#8220;products&#8221;:<br \/>\n[<br \/>\n{&#8220;company&#8221;:&#8221;Company1&#8243;,&#8221;name&#8221;:&#8221;Prod1&#8243;,&#8221;prices&#8221;:[{&#8220;price&#8221;:123.2},{&#8220;price&#8221;:123.6}],&#8221;serialNumber&#8221;:&#8221;12345&#8243;}<br \/>\n{&#8220;company&#8221;:&#8221;Company2&#8243;,&#8221;name&#8221;:&#8221;Prod2&#8243;,&#8221;prices&#8221;:[{&#8220;price&#8221;:234.2},{&#8220;price&#8221;:234.6}],&#8221;serialNumber&#8221;:&#8221;67890&#8243;}<br \/>\n]<br \/>\n}<\/p>\n<p><span style=\"font-weight: bold\">Servlet configuration in web.xml<\/span><br \/>\nNow let&#8217;s configure the application so that the servlet responds to a specific URL. Edit the web.xml file (located in \u201cwar\/WEB-INF\u201d) and paste the following contents (the original contents with the declaration of the greetingService are all removed):<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE web-app\r\n    PUBLIC \"-\/\/Sun Microsystems, Inc.\/\/DTD Web Application 2.3\/\/EN\"\r\n    \"http:\/\/java.sun.com\/dtd\/web-app_2_3.dtd\"&gt;\r\n\r\n&lt;web-app&gt;\r\n  \r\n  &lt;!-- Servlets --&gt;\r\n  &lt;servlet&gt;\r\n    &lt;servlet-name&gt;ProductsServlet&lt;\/servlet-name&gt;\r\n     &lt;servlet-class&gt;\r\n     com.javacodegeeks.json.gwt.server.ProductsServlet\r\n    &lt;\/servlet-class&gt;\r\n  &lt;\/servlet&gt;\r\n  \r\n  &lt;servlet-mapping&gt;\r\n    &lt;servlet-name&gt;ProductsServlet&lt;\/servlet-name&gt;\r\n    &lt;url-pattern&gt;\/jsongwtproject\/products.json&lt;\/url-pattern&gt;\r\n  &lt;\/servlet-mapping&gt;\r\n  \r\n  &lt;!-- Default page to serve --&gt;\r\n  &lt;welcome-file-list&gt;\r\n    &lt;welcome-file&gt;JsonGwtProject.html&lt;\/welcome-file&gt;\r\n  &lt;\/welcome-file-list&gt;\r\n\r\n&lt;\/web-app&gt;\r\n\r\n<\/pre>\n<p><span style=\"font-weight: bold\">Client side with GWT<\/span><br \/>\nFinally, let&#8217;s create the GWT application&#8217;s entry point named \u201cJsonGwtProject\u201d (the original contents are completely removed). The client will invoke an HTTP GET call to the server, will receive the response in JSON format and then will parse the response. The code is:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.json.gwt.client;\r\n\r\nimport com.google.gwt.core.client.EntryPoint;\r\nimport com.google.gwt.event.dom.client.ClickEvent;\r\nimport com.google.gwt.event.dom.client.ClickHandler;\r\nimport com.google.gwt.http.client.Request;\r\nimport com.google.gwt.http.client.RequestBuilder;\r\nimport com.google.gwt.http.client.RequestCallback;\r\nimport com.google.gwt.http.client.RequestException;\r\nimport com.google.gwt.http.client.Response;\r\nimport com.google.gwt.json.client.JSONArray;\r\nimport com.google.gwt.json.client.JSONObject;\r\nimport com.google.gwt.json.client.JSONParser;\r\nimport com.google.gwt.json.client.JSONValue;\r\nimport com.google.gwt.user.client.Window;\r\nimport com.google.gwt.user.client.ui.Button;\r\nimport com.google.gwt.user.client.ui.RootPanel;\r\n\r\npublic class JsonGwtProject implements EntryPoint {\r\n    \r\n    public void onModuleLoad() {\r\n        \r\n        final Button fetchDataButton = new Button(\"Fetch data\");\r\n        fetchDataButton.addStyleName(\"sendButton\");\r\n        \r\n        RootPanel.get(\"fetchDataButtonContainer\").add(fetchDataButton);\r\n        \r\n        fetchDataButton.addClickHandler(new ClickHandler() {\r\n            public void onClick(ClickEvent event) {\r\n                fetchDataFromServer();\r\n            }\r\n        });\r\n        \r\n    }\r\n\r\n    private void fetchDataFromServer() {\r\n        \r\n        try {\r\n            \r\n            RequestBuilder rb = new RequestBuilder(\r\n                 RequestBuilder.GET, \"\/jsongwtproject\/products.json\");\r\n            \r\n            rb.setCallback(new RequestCallback() {\r\n                @Override\r\n                public void onResponseReceived(Request request, Response response) {\r\n                    parseJsonData(response.getText());\r\n                }\r\n                @Override\r\n                public void onError(Request request, Throwable exception) {\r\n                    Window.alert(\"Error occurred\" + exception.getMessage());\r\n                }\r\n            });\r\n            rb.send();\r\n            \r\n        } \r\n        catch (RequestException e) {\r\n            Window.alert(\"Error occurred\" + e.getMessage());\r\n        }\r\n    }\r\n\r\n    private void parseJsonData(String json) {\r\n\r\n        JSONValue value = JSONParser.parse(json);\r\n\r\n        JSONObject productsObj = value.isObject();\r\n        \r\n        JSONArray productsArray = productsObj.get(\"products\").isArray();\r\n        \r\n        if (productsArray != null) {\r\n            \r\n            for (int i=0; i&lt;=productsArray.size()-1; i++) {\r\n                \r\n                JSONObject productObj = productsArray.get(i).isObject();\r\n                \r\n                String name = productObj.get(\"name\").isString().stringValue();\r\n                String company = productObj.get(\"company\").isString().stringValue();\r\n                String serialNumber = productObj.get(\"serialNumber\").isString().stringValue();\r\n                \r\n                StringBuffer priceSb = new StringBuffer();\r\n                \r\n                JSONArray pricesArray = productObj.get(\"prices\").isArray();\r\n                if (pricesArray != null) {\r\n                    for (int j=0; j&lt;=pricesArray.size()-1; j++) {\r\n                        JSONObject priceObj = pricesArray.get(j).isObject();\r\n                        double price = priceObj.get(\"price\").isNumber().doubleValue();\r\n                        if (j!=pricesArray.size()-1) {\r\n                            priceSb.append(\"-\");\r\n                        }\r\n                    }\r\n                }\r\n                String message = \"Product -- \" +\r\n                    \"\\nName: \" + name + \r\n                    \"\\nCompany: \" + company +\r\n                    \"\\nSerial: \" + serialNumber + \r\n                    \"\\nPrices: \" +  priceSb.toString();\r\n                Window.alert(message);\r\n                \r\n            }\r\n            \r\n        }\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>For the HTTP call, the <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/http\/client\/RequestBuilder.html\">RequestBuilder<\/a> class is used. The HTTP method (GET) is defined along with the endpoint URL (where the servlet is configured to respond). Then, an asynchronous callback method is provided using the <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/http\/client\/RequestCallback.html\">RequestCallback<\/a> class. Finally, the request is sent. When the response arrives from the server (if no errors have occurred), our parseJsonData method is invoked.  <span style=\"font-weight: bold\">Parsing JSON data with GWT<\/span> Let&#8217;s see now how to parse the received data using GWT built in methods. Make sure you are importing the JSON classes from the com.google.gwt.json package and not the org.json. First, we use the <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONParser.html\">JSONParser<\/a> to create a <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONValue.html\">JSONValue<\/a> object from the string response. From that we retrieve a <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONObject.html\">JSONObject<\/a> instance using the method <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONObject.html#isObject%28%29\">isObject()<\/a>. Since we know that the response is actually a list of products, we create a <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONArray.html\">JSONArray<\/a> class by invoking the <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONValue.html#isArray%28%29\">isArray()<\/a> method of JSONValue. A loop is then used and we extract the model&#8217;s fields by using the <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONString.html#stringValue%28%29\">stringValue()<\/a> method of the occurring <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/2.0\/com\/google\/gwt\/json\/client\/JSONString.html\">JSONString<\/a> object. Note that in order to extract the multiple price values, we use the same procedure looping through a JSONArray object.  <span style=\"font-weight: bold\">Preparing the HTML file<\/span> The \u201cJsonGwtProject.html\u201dhas also to be changed in order to provide a placeholder for the interface&#8217;s button. Edit it and add the following lines after the \u201cnoscript\u201d declaration: <\/p>\n<pre class=\"brush:xml\">...\r\n    &lt;h1&gt;Web Application Starter Project&lt;\/h1&gt;\r\n\r\n    &lt;table align=\"center\"&gt;\r\n      &lt;tr&gt;\r\n        &lt;td id=\"fetchDataButtonContainer\"&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td colspan=\"2\" style=\"color:red;\" id=\"errorLabelContainer\"&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n    &lt;\/table&gt;\r\n...\r\n<\/pre>\n<p><span style=\"font-weight: bold\">Running the example<\/span> If we run the project, the interface appears, actually there is only a button. Clicking on the button. the JSON data are retrieved, the parsing is performed and the results are printed on the screen: <a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TCdSZekR-2I\/AAAAAAAAAFQ\/Q_oVRmo0RFg\/s1600\/02-ui-parse-json.png\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TCdSZekR-2I\/AAAAAAAAAFQ\/Q_oVRmo0RFg\/s320\/02-ui-parse-json.png\" style=\"cursor: pointer;height: 278px;margin: 0px auto 10px;text-align: center;width: 320px\" \/><\/a>  That would be all. As always, you can download  the Eclipse project from <a href=\"http:\/\/dl.dropbox.com\/u\/7215751\/JavaCodeGeeks\/JsonGWTTutorial\/JsonGwtProject.zip\">here<\/a>.<\/p>\n<p>Enjoy!<\/p>\n<div style=\"margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/gwt-ejb3-maven-jboss-51-integration.html\">GWT EJB3 Maven JBoss 5.1 integration tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/securing-gwt-apps-with-spring-security.html\">Securing GWT apps with Spring Security<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/gwt-2-spring-3-jpa-2-hibernate-35.html\">GWT 2 Spring 3 JPA 2 Hibernate 3.5 Tutorial \u2013 Eclipse and Maven 2 showcase<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/building-your-own-gwt-spring-manen.html\">Building your own GWT Spring Maven Archetype<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/add-captcha-gwt-application.html\">Adding CAPTCHA to your GWT application<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this matter, with a lot of them using XML for the exchange. A not so well known format for performing this task is JSON. JSON (JavaScript Object Notation) is a lightweight data-interchange format. It &hellip;<\/p>\n","protected":false},"author":3,"featured_media":125,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[27,69],"class_list":["post-299","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-google-gwt","tag-json"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Add JSON capabilities into your GWT application - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add JSON capabilities into your GWT application - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-12T23:02:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:16:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ilias Tsagklis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ilias Tsagklis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html\"},\"author\":{\"name\":\"Ilias Tsagklis\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\"},\"headline\":\"Add JSON capabilities into your GWT application\",\"datePublished\":\"2010-07-12T23:02:00+00:00\",\"dateModified\":\"2012-10-21T19:16:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html\"},\"wordCount\":1078,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-gwt-logo.jpg\",\"keywords\":[\"Google GWT\",\"JSON\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html\",\"name\":\"Add JSON capabilities into your GWT application - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-gwt-logo.jpg\",\"datePublished\":\"2010-07-12T23:02:00+00:00\",\"dateModified\":\"2012-10-21T19:16:54+00:00\",\"description\":\"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-gwt-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-gwt-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/add-json-gwt-application.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Add JSON capabilities into your GWT application\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\",\"name\":\"Ilias Tsagklis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"caption\":\"Ilias Tsagklis\"},\"description\":\"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"http:\\\/\\\/www.iliastsagklis.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/iliastsagklis\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/ilias-tsagklis\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add JSON capabilities into your GWT application - Java Code Geeks","description":"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html","og_locale":"en_US","og_type":"article","og_title":"Add JSON capabilities into your GWT application - Java Code Geeks","og_description":"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this","og_url":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2010-07-12T23:02:00+00:00","article_modified_time":"2012-10-21T19:16:54+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg","type":"image\/jpeg"}],"author":"Ilias Tsagklis","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ilias Tsagklis","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html"},"author":{"name":"Ilias Tsagklis","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e"},"headline":"Add JSON capabilities into your GWT application","datePublished":"2010-07-12T23:02:00+00:00","dateModified":"2012-10-21T19:16:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html"},"wordCount":1078,"commentCount":4,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg","keywords":["Google GWT","JSON"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html","url":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html","name":"Add JSON capabilities into your GWT application - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg","datePublished":"2010-07-12T23:02:00+00:00","dateModified":"2012-10-21T19:16:54+00:00","description":"Introduction to JSON While working on web applications, the issue of client-server data exchange always arises. There are various approaches on this","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-gwt-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Add JSON capabilities into your GWT application"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e","name":"Ilias Tsagklis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","caption":"Ilias Tsagklis"},"description":"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.","sameAs":["http:\/\/www.iliastsagklis.com\/","https:\/\/www.linkedin.com\/in\/iliastsagklis"],"url":"https:\/\/www.javacodegeeks.com\/author\/ilias-tsagklis"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=299"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/299\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/125"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}