{"id":14115,"date":"2014-09-08T15:00:16","date_gmt":"2014-09-08T12:00:16","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=14115"},"modified":"2014-09-05T12:22:19","modified_gmt":"2014-09-05T09:22:19","slug":"jaxb-json-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/","title":{"rendered":"JAXB JSON Example"},"content":{"rendered":"<p>In this example we shall show you how to make use of JAXB-JSON. <code><a title=\"JAXB\" href=\"https:\/\/jaxb.java.net\/\" target=\"_blank\">JAXB<\/a><\/code> is a java architecture for XML binding is an efficient technology to convert XML to and from Java Object. <code><a title=\"MOXy\" href=\"http:\/\/www.eclipse.org\/eclipselink\/moxy.php\" target=\"_blank\">EclipseLink JAXB (MOXy)<\/a><\/code> is one of <code><a title=\"JAXB\" href=\"https:\/\/jaxb.java.net\/\" target=\"_blank\">JAXB<\/a><\/code> implementation which is mostly used to create java classes from XML or JSON. In Java <code><a title=\"JAXB\" href=\"https:\/\/jaxb.java.net\/\" target=\"_blank\">JAXB<\/a><\/code> provides two general purpose implementation.<\/p>\n<ul>\n<li><code><b>Marshalling<\/b><\/code> \u2013 It Converts a Java object into XML or JSON.<\/li>\n<li><code><b>Unmarshalling<\/b><\/code> \u2013 It Converts XML or JSON into a Java Object.<\/li>\n<\/ul>\n<p>Now, We will demonstrate the native object-to-JSON binding MOXy JAXB introduced in EclipseLink 2.4. With MOXy as your JAXB provider you can produce\/consume JSON using the standard JAXB APIs (available in Java SE 6) without adding any compile time dependencies.<\/p>\n<h2>Example:<\/h2>\n<h3>1. MOXy Dependency:<\/h3>\n<pre class=\"brush:xml\">    &lt;dependencies&gt;\r\n   \t &lt;dependency&gt;\r\n   \t\t &lt;groupId&gt;org.eclipse.persistence&lt;\/groupId&gt;\r\n   \t\t &lt;artifactId&gt;org.eclipse.persistence.moxy&lt;\/artifactId&gt;\r\n   \t\t &lt;version&gt;2.5.2&lt;\/version&gt;\r\n   \t &lt;\/dependency&gt;\r\n         &lt;dependency&gt;\r\n   \t\t &lt;groupId&gt;javax.xml.bind&lt;\/groupId&gt;\r\n   \t\t &lt;artifactId&gt;jaxb-api&lt;\/artifactId&gt;\r\n   \t\t &lt;version&gt;2.2.11&lt;\/version&gt;\r\n   \t &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;\r\n\r\n<\/pre>\n<h2>2.\u00a0Simple Pojo:<\/h2>\n<p>Create an employee object, initialized with some values, it will be converted to \/ from JSON.<\/p>\n<p><em><span style=\"text-decoration: underline\">Employee.java<\/span>:<\/em><\/p>\n<pre class=\"brush:java\">package com.jcg.jaxb.json;\r\n\r\nimport java.util.List;\r\n\r\nimport javax.xml.bind.annotation.XmlRootElement;\r\n\r\n\/**\r\n * @author ashraf_sarhan\r\n * \r\n *\/\r\n@XmlRootElement\r\npublic class Employee {\r\n\r\n\tprivate int id;\r\n\r\n\tprivate String name;\r\n\r\n\tprivate List skills;\r\n\r\n\tpublic int getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(int id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\r\n\tpublic List getSkills() {\r\n\t\treturn skills;\r\n\t}\r\n\r\n\tpublic void setSkills(List skills) {\r\n\t\tthis.skills = skills;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<h2>3. Marshal Java Object to JSON:<\/h2>\n<p>Create a JaxBContext using the Employee class then convert the \u201cemployee\u201d Java object into JSON formatted string using Marshaller object with following three properties: <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li><code>MEDIA_TYPE<\/code> \u2013 Determine the produced output media type (JSON, XML).<\/li>\n<li><code>JSON_INCLUDE_ROOT<\/code> \u2013 Flag to determine whether you want to include the JSON root element in the produced output or not.<\/li>\n<li><code>JAXB_FORMATTED_OUTPUT<\/code> \u2013 Flag to determine whether you want to format the produced output or not.<\/li>\n<\/ul>\n<p><em><span style=\"text-decoration: underline\">MarshallerDemo.java<\/span>:<\/em><\/p>\n<pre class=\"brush:java\">package com.jcg.jaxb.json;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport javax.xml.bind.JAXBContext;\r\nimport javax.xml.bind.JAXBException;\r\nimport javax.xml.bind.Marshaller;\r\n\r\nimport org.eclipse.persistence.jaxb.MarshallerProperties;\r\n\r\n\/**\r\n * @author ashraf_sarhan\r\n * \r\n *\/\r\npublic class MarshallerDemo {\r\n\r\n\t\/**\r\n\t * @param args\r\n\t * @throws JAXBException\r\n\t * Marshaller POJO to JSON using EclipseLink MOXy\r\n\t *\/\r\n\tpublic static void main(String[] args) throws JAXBException {\r\n\r\n\t\t\/\/ Creating a new employee pojo object with data\r\n\t\tEmployee employee = new Employee();\r\n\t\temployee.setId(1);\r\n\t\temployee.setName(\"Ashraf\");\r\n\t\tList skills = new ArrayList();\r\n\t\tskills.add(\"java\");\r\n\t\tskills.add(\"sql\");\r\n\t\temployee.setSkills(skills);\r\n\r\n\t\t\/\/ Create a JaxBContext\r\n\t\tJAXBContext jc = JAXBContext.newInstance(Employee.class);\r\n\r\n\t\t\/\/ Create the Marshaller Object using the JaxB Context\r\n\t\tMarshaller marshaller = jc.createMarshaller();\r\n\t\t\r\n\t\t\/\/ Set the Marshaller media type to JSON or XML\r\n\t\tmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE,\r\n\t\t\t\t\"application\/json\");\r\n\t\t\r\n\t\t\/\/ Set it to true if you need to include the JSON root element in the JSON output\r\n\t\tmarshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true);\r\n\t\t\r\n\t\t\/\/ Set it to true if you need the JSON output to formatted\r\n\t\tmarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);\r\n\t\t\r\n\t\t\/\/ Marshal the employee object to JSON and print the output to console\r\n\t\tmarshaller.marshal(employee, System.out);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p><em><span style=\"text-decoration: underline\">Output<\/span>:<\/em><\/p>\n<pre class=\"brush:bash\">{\r\n   \"employee\" : {\r\n      \"id\" : 1,\r\n      \"name\" : \"Ashraf\",\r\n      \"skills\" : [ \"java\", \"sql\" ]\r\n   }\r\n}\r\n<\/pre>\n<h2>4. Unmarshal JSON to Java Object:<\/h2>\n<p>Create a JaxBContext using the Employee class then read the provided JSON string and convert it back to the &#8220;employee&#8221; Java object using Unmarshaller object with following two properties: <\/p>\n<ul>\n<li><code>MEDIA_TYPE<\/code> \u2013 Determine the provided input media type (JSON, XML).<\/li>\n<li><code>JSON_INCLUDE_ROOT<\/code> \u2013 Flag to determine whether you want to include the JSON root element in the provided input or not.<\/li>\n<\/ul>\n<p><em><span style=\"text-decoration: underline\">UnmarshallerDemo.java<\/span>:<\/em><\/p>\n<pre class=\"brush:java\">package com.jcg.jaxb.json;\r\n\r\nimport java.io.StringReader;\r\n\r\nimport javax.xml.bind.JAXBContext;\r\nimport javax.xml.bind.JAXBException;\r\nimport javax.xml.bind.Unmarshaller;\r\nimport javax.xml.transform.stream.StreamSource;\r\n\r\nimport org.apache.commons.lang3.StringUtils;\r\nimport org.eclipse.persistence.jaxb.UnmarshallerProperties;\r\n\r\n\/**\r\n * @author ashraf_sarhan\r\n * \r\n *\/\r\npublic class UnmarshallerDemo {\r\n\r\n\t\/**\r\n\t * @param args\r\n\t * @throws JAXBException\r\n\t *             Unmarshaller JSON to POJO using EclipseLink MOXy\r\n\t *\/\r\n\tpublic static void main(String[] args) throws JAXBException {\r\n\r\n\t\t\/\/ Create a JaxBContext\r\n\t\tJAXBContext jc = JAXBContext.newInstance(Employee.class);\r\n\r\n\t\t\/\/ Create the Unmarshaller Object using the JaxB Context\r\n\t\tUnmarshaller unmarshaller = jc.createUnmarshaller();\r\n\r\n\t\t\/\/ Set the Unmarshaller media type to JSON or XML\r\n\t\tunmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE,\r\n\t\t\t\t\"application\/json\");\r\n\r\n\t\t\/\/ Set it to true if you need to include the JSON root element in the\r\n\t\t\/\/ JSON input\r\n\t\tunmarshaller\r\n\t\t\t\t.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, true);\r\n\r\n\t\t\/\/ Create the StreamSource by creating StringReader using the JSON input\r\n\t\tStreamSource json = new StreamSource(\r\n\t\t\t\tnew StringReader(\r\n\t\t\t\t\t\t\"{\\\"employee\\\":{\\\"id\\\":1,\\\"name\\\":\\\"Ashraf\\\",\\\"skills\\\":[\\\"java\\\",\\\"sql\\\"]}}\"));\r\n\r\n\t\t\/\/ Getting the employee pojo again from the json\r\n\t\tEmployee employee = unmarshaller.unmarshal(json, Employee.class)\r\n\t\t\t\t.getValue();\r\n\r\n\t\t\/\/ Print the employee data to console\r\n\t\tSystem.out.println(\"Employee Id: \" + employee.getId());\r\n\t\tSystem.out.println(\"\\nEmployee Name: \" + employee.getName());\r\n\t\tSystem.out.println(\"\\nEmployee Skills: \"\r\n\t\t\t\t+ StringUtils.join(employee.getSkills(), ','));\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p><em><span style=\"text-decoration: underline\">Output<\/span>:<\/em><\/p>\n<pre class=\"brush:bash\">Employee Id: 1\r\nEmployee Name: Ashraf\r\nEmployee Skills: java,sql\r\n<\/pre>\n<div class=\"tip\">\n<p><strong>Tip<\/strong><\/p>\n<p><strong>Specify MOXy as the JAXB Provider (jaxb.properties)<\/strong><br \/>\nTo configure MOXy as your JAXB provider simply add a file named jaxb.properties in the same package as your domain model with the following entry:<\/p>\n<pre class=\"brush:bash\">javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory\r\n<\/pre>\n<\/div>\n<h2>5. Download the Source Code of this example:<\/h2>\n<p>This was an example of how to use JAXB-JSON to marshal and unmarshal java POJO using the native Object to JSON binding of <a title=\"moxy\" href=\"http:\/\/www.eclipse.org\/eclipselink\/moxy.php\" target=\"_blank\">MOXy JAXB<\/a>.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a title=\"JAXB-JSON Example Code\" href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/jaxb-json-example-code.zip\" target=\"_blank\"><strong>JAXB-JSON Example Code<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to and from Java Object. EclipseLink JAXB (MOXy) is one of JAXB implementation which is mostly used to create java classes from XML or JSON. In Java &hellip;<\/p>\n","protected":false},"author":24,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[391],"tags":[673,393,1029,674],"class_list":["post-14115","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bind","tag-eclipselink-2-4","tag-jaxb","tag-json","tag-moxy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JAXB JSON Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAXB JSON Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ashraf.sar7an\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-08T12:00:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-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=\"Ashraf Sarhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/ashraf_sarhan\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashraf Sarhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\"},\"author\":{\"name\":\"Ashraf Sarhan\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/553eb8f56e9ffb76e6bcc85d6157fc91\"},\"headline\":\"JAXB JSON Example\",\"datePublished\":\"2014-09-08T12:00:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\"},\"wordCount\":353,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"EclipseLink 2.4\",\"JAXB\",\"json\",\"MOXy\"],\"articleSection\":[\"bind\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\",\"name\":\"JAXB JSON Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2014-09-08T12:00:16+00:00\",\"description\":\"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"xml\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"bind\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/bind\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"JAXB JSON Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/553eb8f56e9ffb76e6bcc85d6157fc91\",\"name\":\"Ashraf Sarhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/cropped-ashraf_sarhan_photo-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/cropped-ashraf_sarhan_photo-96x96.jpg\",\"caption\":\"Ashraf Sarhan\"},\"description\":\"Ashraf Sarhan is a passionate software engineer, an open source enthusiast, has a Bsc. degree in Computer and Information Systems from Alexandria University. He is experienced in building large, scalable and distributed enterprise applications\/service in multiple domains. He also has a keen interest in JavaEE, SOA, Agile and Big Data technologies.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\",\"https:\/\/www.facebook.com\/ashraf.sar7an\",\"https:\/\/eg.linkedin.com\/in\/ashrafsarhan\",\"https:\/\/x.com\/http:\/\/twitter.com\/ashraf_sarhan\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/ashraf-sarhan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JAXB JSON Example - Java Code Geeks","description":"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to","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:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/","og_locale":"en_US","og_type":"article","og_title":"JAXB JSON Example - Java Code Geeks","og_description":"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/www.facebook.com\/ashraf.sar7an","article_published_time":"2014-09-08T12:00:16+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Ashraf Sarhan","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/ashraf_sarhan","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ashraf Sarhan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/"},"author":{"name":"Ashraf Sarhan","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/553eb8f56e9ffb76e6bcc85d6157fc91"},"headline":"JAXB JSON Example","datePublished":"2014-09-08T12:00:16+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/"},"wordCount":353,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["EclipseLink 2.4","JAXB","json","MOXy"],"articleSection":["bind"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/","name":"JAXB JSON Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2014-09-08T12:00:16+00:00","description":"In this example we shall show you how to make use of JAXB-JSON. JAXB is a java architecture for XML binding is an efficient technology to convert XML to","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/bind\/jaxb-json-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"xml","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/"},{"@type":"ListItem","position":5,"name":"bind","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/bind\/"},{"@type":"ListItem","position":6,"name":"JAXB JSON Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/553eb8f56e9ffb76e6bcc85d6157fc91","name":"Ashraf Sarhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/cropped-ashraf_sarhan_photo-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/cropped-ashraf_sarhan_photo-96x96.jpg","caption":"Ashraf Sarhan"},"description":"Ashraf Sarhan is a passionate software engineer, an open source enthusiast, has a Bsc. degree in Computer and Information Systems from Alexandria University. He is experienced in building large, scalable and distributed enterprise applications\/service in multiple domains. He also has a keen interest in JavaEE, SOA, Agile and Big Data technologies.","sameAs":["http:\/\/www.javacodegeeks.com","https:\/\/www.facebook.com\/ashraf.sar7an","https:\/\/eg.linkedin.com\/in\/ashrafsarhan","https:\/\/x.com\/http:\/\/twitter.com\/ashraf_sarhan"],"url":"https:\/\/examples.javacodegeeks.com\/author\/ashraf-sarhan\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=14115"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14115\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=14115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=14115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=14115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}