Forum Stats

  • 3,726,735 Users
  • 2,245,248 Discussions
  • 7,852,382 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

parsing a json to a List<List<String>

1102964
1102964 Member Posts: 37

I have json input as

<span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>  </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"data"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">:[</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>  </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>  </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"keys"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">:</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">[</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"123"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"456"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"789"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">],</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/><br/>  </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"subkeys"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">:</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">[</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>   </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">[</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"1"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"2"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"3"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">],</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>   </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">[</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"1"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"2"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"3"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">],</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>   </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">[</span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"1"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"2"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="str" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">"3"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>   </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>  </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">}</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/>  </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"><br/></span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">}</span>

I need to get this as List &lt; List &lt; String &gt; &gt; or List &lt; String[] &gt;.

@XmlRootElement(name="data")public class MonitoringDataRequest {    private List<MonitoringData> data;       @XmlElement    public void setData(List<MonitoringData> data) {        this.data = data;    }    public List<MonitoringData> getData() {        return data;    }    }@XmlRootElement(name="monitoring_data")public class MonitoringData {   private List<String> keys;    private List<SubkeyData> subKeys;    @XmlElement    public void setKeys(List<String> keys) {        this.keys = keys;    }    public List<String> getKeys() {        return keys;    }    @XmlElement(name="subkeys")    public void setSubKeys(List<SubkeyData> subKeys) {        this.subKeys = subKeys;    }    public List<SubkeyData> getSubKeys() {        return subKeys;    }}<code style="font-style: inherit; font-weight: inherit; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"><br/></span>@XmlRootElement(name="subkeys")//@XmlAccessorType(XmlAccessType.NONE)public class SubkeyData{      private List<String[]> subkeys;    @XmlElement    public void setSubkeys(List<String[]> subkeys)    {        this.subkeys = subkeys;    }    public List<String[]> getSubkeys()    {        return subkeys;    }}<span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"><br/></span><code style="font-style: inherit; font-weight: inherit; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"><span class="lit" style="color: #7d2727; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">@PUT</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> </span><span class="lit" style="color: #7d2727; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">@Path</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">(</span><span class="str" style="color: #7d2727; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">"/{key}/"</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">)</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> <br/></span><span class="lit" style="color: #7d2727; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">@Consumes</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">(</span><span class="typ" style="color: #2b91af; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">MediaType</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">.</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">APPLICATION_JSON</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">)</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> <br/></span><span class="lit" style="color: #7d2727; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">@Produces</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">(</span><span class="typ" style="color: #2b91af; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">MediaType</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">.</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">APPLICATION_JSON</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">)</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> <br/></span><span class="kwd" style="color: #101094; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">public</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> </span><span class="typ" style="color: #2b91af; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">MyResponse</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> loadData</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">(</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> <span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; background-color: #eff0f1;">MonitoringDataRequest </span></span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">monReq</span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">)</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;"> </span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">{</span><span class="pln" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">  <br/></span><span class="pun" style="color: #303336; font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit;">}<br/><br/></span>

I got the error like

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions java.util.List is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at java.util.List at private java.util.List foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return

This discussion has been closed.