Showing posts with label Collection Property. Show all posts
Showing posts with label Collection Property. Show all posts

March 15, 2013

Binding to JSON & XML - Handling Collections

One of EclipseLink JAXB (MOXy)'s strengths is the ability to map an object model to both JSON and XML with a single set of metadata.  The one weakness had been that you needed to compromise on the JSON key or XML element for collection properties.  I'm happy to say that this issue has been solved in EclipseLink 2.5 (and EclipseLink 2.4.2), and I will demonstrate below with an example.

You can try this out today by downloading an EclipseLink 2.5.0 (or EclipseLink 2.4.2) nightly build starting on March 15, 2013 from:

December 20, 2012

JAXB - Representing Null and Empty Collections

In this post I will cover how to differentiate between null and empty collections in the XML representation with JAXB (JSR-222).

November 15, 2012

Creating a Generic List Wrapper in JAXB

To marshal/unmarshal a list with a JAXB (JSR-222) implementation you need to create a wrapper object to hold the list. People find this onerous having to create multiple wrapper objects for this purpose.  Below I'll demonstrate that in reality you only need to create one. This post is based on an answer I gave on Stack Overflow.

January 25, 2011

JAXB and Choosing the List Implementation

For elements with max occurs greater than one, JAXB will generate a java.util.List property and the underlying implementation will be java.util.ArrayList.  You can control which list implementation is used through internal and external schema annotations.  You can also use your own domain objects which gives you full control of your object model.  This post will discuss these different options.

September 28, 2010

JAXB & Collection Properties

In this post will examine the different options JAXB offers for representing collections in XML.  We will look at the following annotations:
  • @XmlElement
  • @XmlElementWrapper
  • @XmlList
  • @XmlList and @XmlAttribute
  • @XmlList and @XmlValue