{"id":342,"date":"2011-01-29T17:45:00","date_gmt":"2011-01-29T17:45:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/android-json-parsing-with-gson-tutorial.html"},"modified":"2019-12-02T16:36:10","modified_gmt":"2019-12-02T14:36:10","slug":"android-json-parsing-gson-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html","title":{"rendered":"Android JSON Parsing with Gson Tutorial"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div dir=\"ltr\" style=\"text-align: left;\">\n<p>Apart from XML, <a href=\"http:\/\/www.json.org\/\">JSON<\/a> is a very common format used in API responses. Its simplicity has helped to gain quite the adoption in favor of the more verbose XML. Additionally, JSON can easily be combined with <a href=\"http:\/\/www.javacodegeeks.com\/?tag=restful-web-service\">REST<\/a> producing clear and easy to use APIs. Android includes support for JSON in its SDK as someone can find in the <a href=\"http:\/\/developer.android.com\/reference\/org\/json\/package-summary.html\">JSON package summary<\/a>. However, using those classes, a developer has to deal with low level JSON parsing, which in my opinion is tedious and boring. For this reason, in this tutorial, I am going to show you how to perform automatic JSON parsing.For this purpose we are going to use the <a href=\"http:\/\/code.google.com\/p\/google-gson\/\">Google Gson<\/a> library. From the official site:<\/p>\n<p><i>Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.<\/i><br \/>\n<i>There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.<\/i><br \/>\n[ulp id=&#8217;luHisu6VPL9Mt6IB&#8217;]<\/p>\n<p>Excellent, exactly what we need. Before delving into code, you might want to take a look at the <a href=\"http:\/\/sites.google.com\/site\/gson\/gson-user-guide\">Gson User Guide<\/a> and bookmark the <a href=\"http:\/\/google-gson.googlecode.com\/svn\/trunk\/gson\/docs\/javadocs\/index.html\">Gson API Javadocs<\/a>. Let&#8217;s get started by <a href=\"http:\/\/code.google.com\/p\/google-gson\/downloads\/list\">downloading Gson<\/a>, with the current version being 1.6. We need the gson-1.6.jar from the distribution.<\/p>\n<p>Let&#8217;s proceed with creating an Eclipse project named \u201cAndroidJsonProject\u201d as follows:<\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TUQzF5hSfeI\/AAAAAAAAATM\/CU-lKmU8QS0\/s1600\/01-eclipse-project.png\"><img decoding=\"async\" class=\"alignnone\" style=\"cursor: pointer; height: 320px; margin: 0px auto 10px; text-align: center; width: 307px;\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TUQzF5hSfeI\/AAAAAAAAATM\/CU-lKmU8QS0\/s320\/01-eclipse-project.png\" alt=\"Add the Gson JAR to your project\" width=\"307\" height=\"320\" border=\"0\"><\/a><\/p>\n<p>Add the Gson JAR to your project&#8217;s classpath.<\/p>\n<p>To illustrate how to use Gson for JSON parsing we are going to parse a JSON response from the Twitter API. Check the <a href=\"http:\/\/apiwiki.twitter.com\/w\/page\/22554679\/Twitter-API-Documentation\">Twitter API Documentation<\/a> for more info. We are going to use the <a href=\"http:\/\/apiwiki.twitter.com\/w\/page\/22554756\/Twitter-Search-API-Method:-search\">Search API method<\/a> for performing ad-hoc searches.<\/p>\n<p>For example, for searching Twitter about <a href=\"http:\/\/twitter.com\/#%21\/javacodegeeks\">JavaCodeGeeks<\/a> and retrieving the results in JSON format, here is the corresponding URL:<\/p>\n<p><a href=\"http:\/\/search.twitter.com\/search.json?q=javacodegeeks\">http:\/\/search.twitter.com\/search.json?q=javacodegeeks<\/a><\/p>\n<p>This will give a one line JSON response containing all the relevant info. This one liner is quite hard to read, so a JSON editor would be quite handy. I use the <a href=\"http:\/\/sourceforge.net\/projects\/eclipsejsonedit\/\">Eclipse Json Editor plugin<\/a> and works really well. Here is how the response looks formatted in my Eclipse IDE:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TUQzb2zamUI\/AAAAAAAAATU\/zNnhk7jyIiE\/s1600\/02-eclipse-json.png\"><img decoding=\"async\" style=\"cursor: pointer; height: 226px; margin: 0px auto 10px; text-align: center; width: 320px;\" src=\"http:\/\/4.bp.blogspot.com\/_piNjpdpJZXA\/TUQzb2zamUI\/AAAAAAAAATU\/zNnhk7jyIiE\/s320\/02-eclipse-json.png\" alt=\"\" border=\"0\"><\/a><\/p>\n<p>As you can see, we have a number of results and after that we have some other fields, such as \u201cmax_id\u201d, \u201csince_id\u201d, \u201cquery\u201d etc.<\/p>\n<p>Thus, our main model object, named \u201cSearchResponse\u201d will be as follows:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.json.model;\n\nimport java.util.List;\n\nimport com.google.gson.annotations.SerializedName;\n\npublic class SearchResponse {\n    \n    public List&lt;Result&gt; results;\n    \n    @SerializedName(\"max_id\")\n    public long maxId;\n    \n    @SerializedName(\"since_id\")\n    public int sinceId;\n    \n    @SerializedName(\"refresh_url\")\n    public String refreshUrl;\n    \n    @SerializedName(\"next_page\")\n    public String nextPage;\n    \n    @SerializedName(\"results_per_page\")\n    public int resultsPerPage;\n    \n    public int page;\n    \n    @SerializedName(\"completed_in\")\n    public double completedIn;\n    \n    @SerializedName(\"since_id_str\")\n    public String sinceIdStr;\n    \n    @SerializedName(\"max_id_str\")\n    public String maxIdStr;\n    \n    public String query;\n    \n}\n<\/pre>\n<p>We provide the various public fields (getter\/setters with private fields can also be used) and in those case that the field name does not match the JSON response, we annotate with the <a href=\"http:\/\/google-gson.googlecode.com\/svn\/trunk\/gson\/docs\/javadocs\/com\/google\/gson\/annotations\/SerializedName.html\">SerializedName<\/a> annotation.<\/p>\n<p>Note that we also have a list of results, with the corresponding model class being:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.json.model;\n\nimport com.google.gson.annotations.SerializedName;\n\npublic class Result {\n    \n    @SerializedName(\"from_user_id_str\")\n    public String fromUserIdStr;\n    \n    @SerializedName(\"profile_image_url\")\n    public String profileImageUrl;\n    \n    @SerializedName(\"created_at\")\n    public String createdAt;\n    \n    @SerializedName(\"from_user\")\n    public String fromUser;\n    \n    @SerializedName(\"id_str\")\n    public String idStr;\n    \n    public Metadata metadata;\n    \n    @SerializedName(\"to_user_id\")\n    public String toUserId;\n    \n    public String text;\n    \n    public long id;\n    \n    @SerializedName(\"from_user_id\")\n    public String from_user_id;\n\n    @SerializedName(\"iso_language_code\")\n    public String isoLanguageCode;\n\n    @SerializedName(\"to_user_id_str\")\n    public String toUserIdStr;\n\n    public String source;\n    \n}\n<\/pre>\n<p>Finally, we have one more class named \u201cMetadata\u201d:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.json.model;\n\nimport com.google.gson.annotations.SerializedName;\n\npublic class Metadata {\n    \n    @SerializedName(\"result_type\")\n    public String resultType;\n\n}\n<\/pre>\n<p>Let&#8217;s now see how all these get wired using Gson. Here is our Activity:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.json;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.util.List;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpStatus;\nimport org.apache.http.client.methods.HttpGet;\nimport org.apache.http.impl.client.DefaultHttpClient;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.util.Log;\nimport android.widget.Toast;\n\nimport com.google.gson.Gson;\nimport com.javacodegeeks.android.json.model.Result;\nimport com.javacodegeeks.android.json.model.SearchResponse;\n\npublic class JsonParsingActivity extends Activity {\n    \n    String url = \"http:\/\/search.twitter.com\/search.json?q=javacodegeeks\";\n    \n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        \n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.main);\n        \n        InputStream source = retrieveStream(url);\n        \n        Gson gson = new Gson();\n        \n        Reader reader = new InputStreamReader(source);\n        \n        SearchResponse response = gson.fromJson(reader, SearchResponse.class);\n        \n        Toast.makeText(this, response.query, Toast.LENGTH_SHORT).show();\n        \n        List&lt;Result&gt; results = response.results;\n        \n        for (Result result : results) {\n            Toast.makeText(this, result.fromUser, Toast.LENGTH_SHORT).show();\n        }\n        \n    }\n    \n    private InputStream retrieveStream(String url) {\n        \n        DefaultHttpClient client = new DefaultHttpClient(); \n        \n        HttpGet getRequest = new HttpGet(url);\n          \n        try {\n           \n           HttpResponse getResponse = client.execute(getRequest);\n           final int statusCode = getResponse.getStatusLine().getStatusCode();\n           \n           if (statusCode != HttpStatus.SC_OK) { \n              Log.w(getClass().getSimpleName(), \n                  \"Error \" + statusCode + \" for URL \" + url); \n              return null;\n           }\n\n           HttpEntity getResponseEntity = getResponse.getEntity();\n           return getResponseEntity.getContent();\n           \n        } \n        catch (IOException e) {\n           getRequest.abort();\n           Log.w(getClass().getSimpleName(), \"Error for URL \" + url, e);\n        }\n        \n        return null;\n        \n     }\n    \n}\n<\/pre>\n<p>First, we perform an HTTP GET request and retrieve the resource as a stream (if you need more details on this, check my previous tutorial <a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html\">Android Full App, Part 2: Using the HTTP API<\/a>). We create a <a href=\"http:\/\/google-gson.googlecode.com\/svn\/trunk\/gson\/docs\/javadocs\/com\/google\/gson\/Gson.html\">Gson<\/a> instance and use it to perform the JSON parsing and retrieve our model object with all its fields populated.<\/p>\n<p>Edit your Android manifest XML file and grant permissions for Internet access and then launch the Eclipse configuration. You shall see notifications of the latest Twitter users that have tweeted about <a href=\"http:\/\/twitter.com\/#%21\/javacodegeeks\">JavaCodeGeeks<\/a>.<\/p>\n<p>That&#8217;s all guys, quick JSON parsing in Android with Gson. As always, you can <a href=\"http:\/\/dl.dropbox.com\/u\/7215751\/JavaCodeGeeks\/AndroidJsonParsingTutorial\/AndroidJsonProject.zip\">download the Eclipse project<\/a> created for this tutorial.<\/p>\n<p>Happy mobile coding! Don&#8217;t forget to share!<\/p>\n<\/div>\n<p><strong>Related Articles:<\/strong><\/p>\n<ul style=\"text-align: left;\">\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-application-tutorial.html\">\u201cAndroid Full Application Tutorial\u201d series<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-text-to-speech-application.html\">Android Text-To-Speech Application<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/android-proximity-alerts-tutorial.html\">Android Proximity Alerts Tutorial <\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/add-json-gwt-application.html\">Add JSON capabilities into your GWT application<\/a><\/li>\n<\/ul>\n<div style=\"margin: 0px;\"><strong><i>Related Snippets :<\/i><\/strong><\/div>\n<ul style=\"text-align: left;\">\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/json\/json-parsing-with-gson\">JSON parsing with Gson<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/xml\/parsing-xml-with-sax\">Parsing XML with SAX<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/bluetooth\/bluetoothadapter\/android-bluetooth-example\/\">Android Bluetooth Example<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/ui\/alertdialog\/android-alert-dialog-example-2\/\">Android Alert Dialog Example<\/a><\/li>\n<li><a href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/socket-core\/android-socket-example\/\">Android Socket Example<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Apart from XML, JSON is a very common format used in API responses. Its simplicity has helped to gain quite the adoption in favor of the more verbose XML. Additionally, JSON can easily be combined with REST producing clear and easy to use APIs. Android includes support for JSON in its SDK as someone can &hellip;<\/p>\n","protected":false},"author":3,"featured_media":175,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[83,128,69],"class_list":["post-342","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-core","tag-android-tutorial","tag-gson","tag-json"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android JSON Parsing with Gson Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.\" \/>\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\/2011\/01\/android-json-parsing-gson-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android JSON Parsing with Gson Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.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=\"2011-01-29T17:45:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-02T14:36:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html\"},\"author\":{\"name\":\"Ilias Tsagklis\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\"},\"headline\":\"Android JSON Parsing with Gson Tutorial\",\"datePublished\":\"2011-01-29T17:45:00+00:00\",\"dateModified\":\"2019-12-02T14:36:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html\"},\"wordCount\":698,\"commentCount\":38,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/json-logo.jpg\",\"keywords\":[\"Android Tutorial\",\"Gson\",\"JSON\"],\"articleSection\":[\"Android Core\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html\",\"name\":\"Android JSON Parsing with Gson Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/json-logo.jpg\",\"datePublished\":\"2011-01-29T17:45:00+00:00\",\"dateModified\":\"2019-12-02T14:36:10+00:00\",\"description\":\"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/json-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/json-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/01\\\/android-json-parsing-gson-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Core\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-core\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android JSON Parsing with Gson Tutorial\"}]},{\"@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":"Android JSON Parsing with Gson Tutorial - Java Code Geeks","description":"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.","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\/2011\/01\/android-json-parsing-gson-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Android JSON Parsing with Gson Tutorial - Java Code Geeks","og_description":"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.","og_url":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-01-29T17:45:00+00:00","article_modified_time":"2019-12-02T14:36:10+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html"},"author":{"name":"Ilias Tsagklis","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e"},"headline":"Android JSON Parsing with Gson Tutorial","datePublished":"2011-01-29T17:45:00+00:00","dateModified":"2019-12-02T14:36:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html"},"wordCount":698,"commentCount":38,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-logo.jpg","keywords":["Android Tutorial","Gson","JSON"],"articleSection":["Android Core"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html","name":"Android JSON Parsing with Gson Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-logo.jpg","datePublished":"2011-01-29T17:45:00+00:00","dateModified":"2019-12-02T14:36:10+00:00","description":"Interested to learn more about Gson? Check out our Android JSON Parsing with Gson Tutorial where we will show you how to perform automatic JSON parsing.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/json-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/01\/android-json-parsing-gson-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Core","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-core"},{"@type":"ListItem","position":4,"name":"Android JSON Parsing with Gson Tutorial"}]},{"@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\/342","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=342"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/175"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}