title: Java - A JSONObject text must begin with '{' at character 1
body: <p>I have been trying to solve a JAXB json problem, but i can't seem to figure out what's wrong. The message i get is:</p>
  
  <pre><code>Caused by: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 1 of [{"id":"Daler Kampagne 2","operation":"UPDATE","VoiceIAQStats":{"id":3,"esdId":3,"esdName":"Daler Kampagne 2","nResourcesLoggedIn":0,"nTotalContacts":0,"nHandledContacts":0,"nAbandonedContacts":0,"nDequeuedContacts":0,"avgTalkDuration":0,"longestTalkDuration":0,"avgWaitDuration":0,"longestWaitDuration":0,"longestCurrentlyWaitingDuration":0,"nAvailResources":0,"nInSessionResources":0,"nUnavailResources":0,"nWorkResources":0,"nSelectedResources":0,"nWaitingContacts":0,"nAverageHandlingTimeLowThreshold":0.0,"nAverageHandlingTimeHighThreshold":0.0,"nAverageWaitingTimeLowThreshold":0.0,"nAverageWaitingTimeHighThreshold":0.0,"nAbandonedCallsLowThreshold":0,"nAbandonedCallsHighThreshold":0,"nDequeuedCallsLowThreshold":0,"nDequeuedCallsHighThreshold":0,"nSLAPercentageLowThreshold":0.0,"nSLAPercentageHighThreshold":0.0}},{"id":"Dialer Kampagne 1","operation":"UPDATE","VoiceIAQStats":{"id":2,"esdId":2,"esdName":"Dialer Kampagne 1","nResourcesLoggedIn":0,"nTotalContacts":0,"nHandledContacts":0,"nAbandonedContacts":0,"nDequeuedContacts":0,"avgTalkDuration":0,"longestTalkDuration":0,"avgWaitDuration":0,"longestWaitDuration":0,"longestCurrentlyWaitingDuration":0,"nAvailResources":0,"nInSessionResources":0,"nUnavailResources":0,"nWorkResources":0,"nSelectedResources":0,"nWaitingContacts":0,"nAverageHandlingTimeLowThreshold":0.0,"nAverageHandlingTimeHighThreshold":0.0,"nAverageWaitingTimeLowThreshold":0.0,"nAverageWaitingTimeHighThreshold":0.0,"nAbandonedCallsLowThreshold":0,"nAbandonedCallsHighThreshold":0,"nDequeuedCallsLowThreshold":0,"nDequeuedCallsHighThreshold":0,"nSLAPercentageLowThreshold":0.0,"nSLAPercentageHighThreshold":0.0}},{"id":"ICD01","operation":"UPDATE","VoiceIAQStats":{"id":1,"esdId":1,"esdName":"ICD01","nResourcesLoggedIn":0,"nTotalContacts":0,"nHandledContacts":0,"nAbandonedContacts":0,"nDequeuedContacts":0,"avgTalkDuration":0,"longestTalkDuration":0,"avgWaitDuration":0,"longestWaitDuration":0,"longestCurrentlyWaitingDuration":0,"nAvailResources":0,"nInSessionResources":0,"nUnavailResources":0,"nWorkResources":0,"nSelectedResources":0,"nWaitingContacts":0,"nAverageHandlingTimeLowThreshold":0.0,"nAverageHandlingTimeHighThreshold":0.0,"nAverageWaitingTimeLowThreshold":0.0,"nAverageWaitingTimeHighThreshold":0.0,"nAbandonedCallsLowThreshold":0,"nAbandonedCallsHighThreshold":0,"nDequeuedCallsLowThreshold":0,"nDequeuedCallsHighThreshold":0,"nSLAPercentageLowThreshold":0.0,"nSLAPercentageHighThreshold":0.0}}]
  at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:463)
  at org.codehaus.jettison.json.JSONObject.&lt;init&gt;(JSONObject.java:204)
  at org.codehaus.jettison.mapped.MappedXMLInputFactory.createJSONObject(MappedXMLInputFactory.java:59)
  at org.codehaus.jettison.mapped.MappedXMLInputFactory.createXMLStreamReader(MappedXMLInputFactory.java:44)
  ... 148 more
  </code></pre>
  
  <p>Here is my classes:</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class CiscoStatsResponse {
  
  private String id;
  private String operation;
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  public String getOperation() {
      return operation;
  }
  
  public void setOperation(String operation) {
      this.operation = operation;
  }
  }
  </code></pre>
  
  <p>VoiceIAQStats</p>
  
  <pre><code>package dk.netdesign.wallboard.dataprovider.uccxrest.domain;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement
  public class VoiceIAQStats {
  
  public String getId() {
      return id;
  }
  public void setId(String id) {
      this.id = id;
  }
  public Integer getEsdId() {
      return esdId;
  }
  public void setEsdId(Integer esdId) {
      this.esdId = esdId;
  }
  public String getEsdName() {
      return esdName;
  }
  public void setEsdName(String esdName) {
      this.esdName = esdName;
  }
  public Integer getnResourcesLoggedIn() {
      return nResourcesLoggedIn;
  }
  public void setnResourcesLoggedIn(Integer nResourcesLoggedIn) {
      this.nResourcesLoggedIn = nResourcesLoggedIn;
  }
  public Integer getnTotalContacts() {
      return nTotalContacts;
  }
  public void setnTotalContacts(Integer nTotalContacts) {
      this.nTotalContacts = nTotalContacts;
  }
  public Integer getnHandledContacts() {
      return nHandledContacts;
  }
  public void setnHandledContacts(Integer nHandledContacts) {
      this.nHandledContacts = nHandledContacts;
  }
  public Integer getnAbandonedContacts() {
      return nAbandonedContacts;
  }
  public void setnAbandonedContacts(Integer nAbandonedContacts) {
      this.nAbandonedContacts = nAbandonedContacts;
  }
  public Integer getnDequeuedContacts() {
      return nDequeuedContacts;
  }
  public void setnDequeuedContacts(Integer nDequeuedContacts) {
      this.nDequeuedContacts = nDequeuedContacts;
  }
  public Integer getAvgTalkDuration() {
      return avgTalkDuration;
  }
  public void setAvgTalkDuration(Integer avgTalkDuration) {
      this.avgTalkDuration = avgTalkDuration;
  }
  public Integer getLongestTalkDuration() {
      return longestTalkDuration;
  }
  public void setLongestTalkDuration(Integer longestTalkDuration) {
      this.longestTalkDuration = longestTalkDuration;
  }
  public Integer getAvgWaitDuration() {
      return avgWaitDuration;
  }
  public void setAvgWaitDuration(Integer avgWaitDuration) {
      this.avgWaitDuration = avgWaitDuration;
  }
  public Integer getLongestWaitDuration() {
      return longestWaitDuration;
  }
  public void setLongestWaitDuration(Integer longestWaitDuration) {
      this.longestWaitDuration = longestWaitDuration;
  }
  public Integer getLongestCurrentlyWaitingDuration() {
      return longestCurrentlyWaitingDuration;
  }
  public void setLongestCurrentlyWaitingDuration(
          Integer longestCurrentlyWaitingDuration) {
      this.longestCurrentlyWaitingDuration = longestCurrentlyWaitingDuration;
  }
  public Integer getnAvailResources() {
      return nAvailResources;
  }
  public void setnAvailResources(Integer nAvailResources) {
      this.nAvailResources = nAvailResources;
  }
  public Integer getnInSessionResources() {
      return nInSessionResources;
  }
  public void setnInSessionResources(Integer nInSessionResources) {
      this.nInSessionResources = nInSessionResources;
  }
  public Integer getnUnavailResources() {
      return nUnavailResources;
  }
  public void setnUnavailResources(Integer nUnavailResources) {
      this.nUnavailResources = nUnavailResources;
  }
  public Integer getnWorkResources() {
      return nWorkResources;
  }
  public void setnWorkResources(Integer nWorkResources) {
      this.nWorkResources = nWorkResources;
  }
  public Integer getnSelectedResources() {
      return nSelectedResources;
  }
  public void setnSelectedResources(Integer nSelectedResources) {
      this.nSelectedResources = nSelectedResources;
  }
  public Integer getnWaitingContacts() {
      return nWaitingContacts;
  }
  public void setnWaitingContacts(Integer nWaitingContacts) {
      this.nWaitingContacts = nWaitingContacts;
  }
  public Integer getnAverageHandlingTimeLowThreshold() {
      return nAverageHandlingTimeLowThreshold;
  }
  public void setnAverageHandlingTimeLowThreshold(
          Integer nAverageHandlingTimeLowThreshold) {
      this.nAverageHandlingTimeLowThreshold = nAverageHandlingTimeLowThreshold;
  }
  public Integer getnAverageHandlingTimeHighThreshold() {
      return nAverageHandlingTimeHighThreshold;
  }
  public void setnAverageHandlingTimeHighThreshold(
          Integer nAverageHandlingTimeHighThreshold) {
      this.nAverageHandlingTimeHighThreshold = nAverageHandlingTimeHighThreshold;
  }
  public Integer getnAverageWaitingTimeLowThreshold() {
      return nAverageWaitingTimeLowThreshold;
  }
  public void setnAverageWaitingTimeLowThreshold(
          Integer nAverageWaitingTimeLowThreshold) {
      this.nAverageWaitingTimeLowThreshold = nAverageWaitingTimeLowThreshold;
  }
  public Integer getnAverageWaitingTimeHighThreshold() {
      return nAverageWaitingTimeHighThreshold;
  }
  public void setnAverageWaitingTimeHighThreshold(
          Integer nAverageWaitingTimeHighThreshold) {
      this.nAverageWaitingTimeHighThreshold = nAverageWaitingTimeHighThreshold;
  }
  public Integer getnAbandonedCallsLowThreshold() {
      return nAbandonedCallsLowThreshold;
  }
  public void setnAbandonedCallsLowThreshold(Integer nAbandonedCallsLowThreshold) {
      this.nAbandonedCallsLowThreshold = nAbandonedCallsLowThreshold;
  }
  public Integer getnAbandonedCallsHighThreshold() {
      return nAbandonedCallsHighThreshold;
  }
  public void setnAbandonedCallsHighThreshold(Integer nAbandonedCallsHighThreshold) {
      this.nAbandonedCallsHighThreshold = nAbandonedCallsHighThreshold;
  }
  public Integer getnDequeuedCallsLowThreshold() {
      return nDequeuedCallsLowThreshold;
  }
  public void setnDequeuedCallsLowThreshold(Integer nDequeuedCallsLowThreshold) {
      this.nDequeuedCallsLowThreshold = nDequeuedCallsLowThreshold;
  }
  public Integer getnDequeuedCallsHighThreshold() {
      return nDequeuedCallsHighThreshold;
  }
  public void setnDequeuedCallsHighThreshold(Integer nDequeuedCallsHighThreshold) {
      this.nDequeuedCallsHighThreshold = nDequeuedCallsHighThreshold;
  }
  public Integer getnSLAPercentageLowThreshold() {
      return nSLAPercentageLowThreshold;
  }
  public void setnSLAPercentageLowThreshold(Integer nSLAPercentageLowThreshold) {
      this.nSLAPercentageLowThreshold = nSLAPercentageLowThreshold;
  }
  public Integer getnSLAPercentageHighThreshold() {
      return nSLAPercentageHighThreshold;
  }
  public void setnSLAPercentageHighThreshold(Integer nSLAPercentageHighThreshold) {
      this.nSLAPercentageHighThreshold = nSLAPercentageHighThreshold;
  }
  String id;
  Integer esdId;
  String esdName;
  Integer nResourcesLoggedIn;
  Integer nTotalContacts;
  Integer nHandledContacts;
  Integer nAbandonedContacts;
  Integer nDequeuedContacts;
  Integer avgTalkDuration;
  Integer longestTalkDuration;
  Integer avgWaitDuration;
  Integer longestWaitDuration;
  Integer longestCurrentlyWaitingDuration;
  Integer nAvailResources;
  Integer nInSessionResources;
  Integer nUnavailResources;
  Integer nWorkResources;
  Integer nSelectedResources;
  Integer nWaitingContacts;
  Integer nAverageHandlingTimeLowThreshold;
  Integer nAverageHandlingTimeHighThreshold;
  Integer nAverageWaitingTimeLowThreshold;
  Integer nAverageWaitingTimeHighThreshold;
  Integer nAbandonedCallsLowThreshold;
  Integer nAbandonedCallsHighThreshold;
  Integer nDequeuedCallsLowThreshold;
  Integer nDequeuedCallsHighThreshold;
  Integer nSLAPercentageLowThreshold;
  Integer nSLAPercentageHighThreshold;
  }
  </code></pre>
  
  <p>VoiceIAQStatsResponse:</p>
  
  <pre><code>package dk.netdesign.wallboard.dataprovider.uccxrest.domain;
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class VoiceIAQStatsResponse extends CiscoStatsResponse {
  
  @XmlElement(name = "VoiceIAQStats")
  private VoiceIAQStats voiceIAQStats;
  
  public VoiceIAQStats getVoiceIAQStats() {
      return voiceIAQStats;
  }
  
  public void setVoiceIAQStats(VoiceIAQStats voiceIAQStats) {
      this.voiceIAQStats = voiceIAQStats;
  }
  
  }
  </code></pre>
  
  <p>The json looks like this(which seems correct to me?)</p>
  
  <pre><code>[{
  "id": "Daler Kampagne 2",
  "operation": "UPDATE",
  "VoiceIAQStats": {
      "id": 3,
      "esdId": 3,
      "esdName": "Daler Kampagne 2",
      "nResourcesLoggedIn": 0,
      "nTotalContacts": 0,
      "nHandledContacts": 0,
      "nAbandonedContacts": 0,
      "nDequeuedContacts": 0,
      "avgTalkDuration": 0,
      "longestTalkDuration": 0,
      "avgWaitDuration": 0,
      "longestWaitDuration": 0,
      "longestCurrentlyWaitingDuration": 0,
      "nAvailResources": 0,
      "nInSessionResources": 0,
      "nUnavailResources": 0,
      "nWorkResources": 0,
      "nSelectedResources": 0,
      "nWaitingContacts": 0,
      "nAverageHandlingTimeLowThreshold": 0.0,
      "nAverageHandlingTimeHighThreshold": 0.0,
      "nAverageWaitingTimeLowThreshold": 0.0,
      "nAverageWaitingTimeHighThreshold": 0.0,
      "nAbandonedCallsLowThreshold": 0,
      "nAbandonedCallsHighThreshold": 0,
      "nDequeuedCallsLowThreshold": 0,
      "nDequeuedCallsHighThreshold": 0,
      "nSLAPercentageLowThreshold": 0.0,
      "nSLAPercentageHighThreshold": 0.0
     }
       }, {
  "id": "Dialer Kampagne 1",
  "operation": "UPDATE",
  "VoiceIAQStats": {
      "id": 2,
      "esdId": 2,
      "esdName": "Dialer Kampagne 1",
      "nResourcesLoggedIn": 0,
      "nTotalContacts": 0,
      "nHandledContacts": 0,
      "nAbandonedContacts": 0,
      "nDequeuedContacts": 0,
      "avgTalkDuration": 0,
      "longestTalkDuration": 0,
      "avgWaitDuration": 0,
      "longestWaitDuration": 0,
      "longestCurrentlyWaitingDuration": 0,
      "nAvailResources": 0,
      "nInSessionResources": 0,
      "nUnavailResources": 0,
      "nWorkResources": 0,
      "nSelectedResources": 0,
      "nWaitingContacts": 0,
      "nAverageHandlingTimeLowThreshold": 0.0,
      "nAverageHandlingTimeHighThreshold": 0.0,
      "nAverageWaitingTimeLowThreshold": 0.0,
      "nAverageWaitingTimeHighThreshold": 0.0,
      "nAbandonedCallsLowThreshold": 0,
      "nAbandonedCallsHighThreshold": 0,
      "nDequeuedCallsLowThreshold": 0,
      "nDequeuedCallsHighThreshold": 0,
      "nSLAPercentageLowThreshold": 0.0,
      "nSLAPercentageHighThreshold": 0.0
   }
    }, {
  "id": "ICD01",
  "operation": "UPDATE",
  "VoiceIAQStats": {
      "id": 1,
      "esdId": 1,
      "esdName": "ICD01",
      "nResourcesLoggedIn": 0,
      "nTotalContacts": 0,
      "nHandledContacts": 0,
      "nAbandonedContacts": 0,
      "nDequeuedContacts": 0,
      "avgTalkDuration": 0,
      "longestTalkDuration": 0,
      "avgWaitDuration": 0,
      "longestWaitDuration": 0,
      "longestCurrentlyWaitingDuration": 0,
      "nAvailResources": 0,
      "nInSessionResources": 0,
      "nUnavailResources": 0,
      "nWorkResources": 0,
      "nSelectedResources": 0,
      "nWaitingContacts": 0,
      "nAverageHandlingTimeLowThreshold": 0.0,
      "nAverageHandlingTimeHighThreshold": 0.0,
      "nAverageWaitingTimeLowThreshold": 0.0,
      "nAverageWaitingTimeHighThreshold": 0.0,
      "nAbandonedCallsLowThreshold": 0,
      "nAbandonedCallsHighThreshold": 0,
      "nDequeuedCallsLowThreshold": 0,
      "nDequeuedCallsHighThreshold": 0,
      "nSLAPercentageLowThreshold": 0.0,
      "nSLAPercentageHighThreshold": 0.0
  }
  }]
  </code></pre>
  
  <p>EDIT: This is the method that i use to invoke the webservice and return a list of VoiceIAQStatsResponse.</p>
  
  <pre><code>public List&lt;VoiceIAQStatsResponse&gt; getVoiceIAQStatsResponse() {
  
      WebTarget resourceWebTarget = getBaseTarget().path("VoiceIAQStats");
  
      Invocation.Builder invocationBuilder = resourceWebTarget
              .request(MediaType.APPLICATION_JSON);
  
      javax.ws.rs.core.Response response = invocationBuilder.get();
  
      System.out.println("ÅH ABE" + response.toString());
  
      GenericType&lt;List&lt;VoiceIAQStatsResponse&gt;&gt; type = new GenericType&lt;List&lt;VoiceIAQStatsResponse&gt;&gt;() {
      };
      logger.debug(response.getStatusInfo().toString());
  
      List&lt;VoiceIAQStatsResponse&gt; list = null;
      if (response.getStatusInfo().getFamily().compareTo(Response.Status.Family.SUCCESSFUL) == 0) {
  
          list = response.readEntity(type);
      } else {
          list = Collections.EMPTY_LIST;
      }
  
      return list;
  }
  </code></pre>
  
  <p>I was really hoping for someone with experience with this problem - I can't seem to figure out the problem.</p>