Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting List wrapper to List using JAXB
    primarykey
    data
    text
    <p>I'm trying to annotate a set of data objects with JAXB binding annotations so that this set of data objects can be properly marshaled as JSON using CXF. I'm running into an issue with a class that is basically just a wrapper around ArrayList:</p> <pre><code>class IntegerListWrapper { private ArrayList&lt;Integer&gt; integerList; ... } </code></pre> <p>Some of my data objects refer to this class:</p> <pre><code>class DataObjectFoo { ... public IntegerListWrapper getDataIDs() { ... } ... } </code></pre> <p>I'm looking for the output to be:</p> <pre><code>"DataObjectFoo" : { "dataIDs" : [1, 2, ..., n] // Array of Data IDs } </code></pre> <p>I tried annotating the IDList class itself but it left me with this:</p> <pre><code>"DataObjectFoo" : { "dataIDs" : { "integerList" : [1, 2, ..., n] } // Extra nesting } </code></pre> <p>I tried writing an XmlAdapter but got mixed results:</p> <pre><code>// Throws an error... "Can't bind to interface" public final class IDListAdapter extends XmlAdapter&lt;List&lt;Integer&gt;, IDList&gt; { // Does not produce any output public final class IDListAdapter extends XmlAdapter&lt;ArrayList&lt;Integer&gt;, IDList&gt; { // Produces output with extra nesting like above public final class IDListAdapter extends XmlAdapter&lt;Integer[]&gt;, IDList&gt; </code></pre> <p>So I have two questions:</p> <ol> <li>How do I get the desired output (without converting IDList to something else in my data objects)?</li> <li>Why did the second XmlAdapter (using ArrayList) not produce output?</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload