title: Parsing Json Object to Json Array using Gson
body: <p>I am calling a webservice which gives me a json like this </p>
  
  <pre><code>{
      "discussions": [{
          "id": 54,
          "name": "Test Discusssion",
          "discussion": 41,
          "created": 1472816138,
          "modified": 1472816138,
          "subject": "Test Discusssion",
          "message": "&lt;p&gt;Welcome all to test discussion&lt;\/p&gt;",
      }],
      "warnings": []
  }
  </code></pre>
  
  <p>But in android I am parsing it as </p>
  
  <pre><code>ArrayList&lt;MoodleDiscussion&gt; mDiscussions = gson.fromJson(reader,
        new TypeToken&lt;List&lt;MoodleDiscussion&gt;&gt;() {
        }.getType());
  </code></pre>
  
  <p>And the error I am getting is</p>
  
  <p><strong>java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT</strong></p>
  
  <p>I want to convert the received json into an array how should I ?</p>
  
  <p>Here is the MoodleDiscussion class</p>
  
  <pre><code>public class MoodleDiscussion extends SugarRecord &lt; MoodleDiscussion &gt; {@
      SerializedName("id") int discussionid;@
      SerializedName("name") String name;@
      SerializedName("subject") String subject;
      public int getDiscussionid() {
          return discussionid;
      }
      public String getName() {
          return name;
      }
      public int getUserid() {
          return userid;
      }
      public String getSubject() {
          return subject;
      }
  }
  </code></pre>