0 Replies Latest reply on Jun 13, 2017 9:09 AM by 1102964

    parsing a json to a List<List<String>

    1102964

      I have json input as

      {
       
      "data" :[
       
      {
       
      "keys": ["123","456","789"],

       
      "subkeys": [
        
      ["1", "2", "3"],
        
      ["1", "2", "3"],
        
      ["1", "2", "3"]
        
      ]
       
      }
       
      ]
      }

      I need to get this as List < List < String > > or List < String[] >.

      @PUT @Path("/{key}/") 
      @Consumes(MediaType.APPLICATION_JSON)
      @Produces(MediaType.APPLICATION_JSON)
      public MyResponse loadData( MonitoringDataRequest monReq) { 
      }

      @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;

          }

       

      }


      @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;

          }

       

       

       

       

      }


      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