title: Kotlin convert json array to model list using GSON
body: <p>I am not able to convert a JSON Array into a <code>GroupModel</code> array.  Below is the JSON I used:</p>
  
  <pre><code>[{
    "description":"My expense to others",
    "items":["aaa","bbb"],
    "name":"My Expense"
   },
   {
    "description":"My expense to others","
    items":["aaa","bbb"],
    "name":"My Expense"
   }]
  </code></pre>
  
  <p>and the <code>GroupModel</code> class is:</p>
  
  <pre><code>class GroupModel {
      var name: String? = null
      var description: String? = null
      var items: MutableList&lt;String&gt;? = null
  
      constructor(name: String, description: String, items: MutableList&lt;String&gt;) {
          this.name = name
          this.description = description
          this.items = items
      }
  }
  </code></pre>
  
  <p>and trying the following code results in an <code>Exception</code>:</p>
  
  <blockquote>
    <p>com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected 
    BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $</p>
  </blockquote>
  
  <p>The code:</p>
  
  <pre><code>var model = gson.fromJson&lt;Array&lt;GroupModel&gt;&gt;(inputString, GroupModel::class.java)
  </code></pre>