title: Gson: Not a JSON Object
body: <p>I have the following String passed to server:</p>
  
  <pre><code>{
      "productId": "",
      "sellPrice": "",
      "buyPrice": "",
      "quantity": "",
      "bodies": [
          {
              "productId": "1",
              "sellPrice": "5",
              "buyPrice": "2",
              "quantity": "5"
          },
          {
              "productId": "2",
              "sellPrice": "3",
              "buyPrice": "1",
              "quantity": "1"
          }
      ]
  }
  </code></pre>
  
  <p>which is a valid json for <a href="http://jsonlint.com/" rel="noreferrer">http://jsonlint.com/</a></p>
  
  <p>I want to get the bodies array field.</p>
  
  <p>That's how I'm doing it:</p>
  
  <pre><code>Gson gson = new Gson();
  JsonObject object = gson.toJsonTree(value).getAsJsonObject();
  JsonArray jsonBodies = object.get("bodies").getAsJsonArray();
  </code></pre>
  
  <p>But on the second line I'm getting exception listed below:</p>
  
  <pre><code>HTTP Status 500 - Not a JSON Object: "{\"productId\":\"\",\"sellPrice\":\"\",\"buyPrice\":\"\",\"quantity\":\"\",\"bodies\":[{\"productId\":\"1\",\"sellPrice\":\"5\",\"buyPrice\":\"2\",\"quantity\":\"5\"},{\"productId\":\"2\",\"sellPrice\":\"3\",\"buyPrice\":\"1\",\"quantity\":\"1\"}]}"
  </code></pre>
  
  <p>How to do it properly then ?</p>