title: Parse JSON to Java Object using GSON
body: <p>I am trying to map a json document from the jenkins API to my own java objects. The json document looks as follows: </p>
  
  <pre><code>{
      "assignedLabels": [
          {}
      ],
      "mode": "EXCLUSIVE",
      "nodeDescription": "Jenkins Master-Knoten",
      "nodeName": "",
      "numExecutors": 2,
      "description": null,
      "jobs": [
          {
              "name": "Job 1",
              "url": "https://build.example.com/jenkins/job/Job1/",
              "color": "disabled"
          },
          {
              "name": "Job 2",
              "url": "https://build.example.com/jenkins/job/Job2/",
              "color": "blue"
          }
      ],
      "overallLoad": {},
      "primaryView": {
          "name": "Alle",
          "url": "https://build.example.com/jenkins/"
      },
      "quietingDown": false,
      "slaveAgentPort": 0,
      "unlabeledLoad": {},
      "useCrumbs": false,
      "useSecurity": true,
      "views": [
          {
              "name": "Selection",
              "url": "https://build.example.com/jenkins/view/-All%Selection/"
          },
          {
              "name": "All",
              "url": "https://build.example.com/jenkins/"
          }
      ]
  }
  </code></pre>
  
  <p>My java model looks like this:</p>
  
  <pre><code>public class JenkinsServer {
      private List&lt;String&gt; assignedLabels;
      private String url;
  
      private String mode;
      private String nodeName;
      private String nodeDescription;
      private String description;
  
      private boolean useSecurity;
      private boolean quietingDown;
  
      private JenkinsServerView primaryView;
      private List&lt;JenkinsServerView&gt; views;
      private List&lt;JenkinsJob&gt; jobs;
  
      // getters &amp; setters
  }
  </code></pre>
  
  <p>What I am doing now is I call </p>
  
  <pre><code>Gson gson = new Gson();
  JenkinsServer server = gson.fromJson( reader, JenkinsServer.class );
  </code></pre>
  
  <p>But I receive this exception</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 6 column 5
      at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:374)
      at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)
  </code></pre>
  
  <p>I've been searching the internet for a solution but could not figure out what I'm doing wrong. Maybe you guys know :-)</p>