title: Parsing JsonObject to List<Map<String, Object>> using Gson?
body: <p>I'm trying to parse a string representation of a JSON object into a List of maps.
  The json object will be structured something like the following:</p>
  
  <pre><code>[
   {       
    "first_name": "fname1",
    "last_name": "lname1"
   },
   {
    "first_name": "fname2",
     "last_name": "lname2"
   }
   .
   .
   .
  ]
  </code></pre>
  
  <p>The only thing that is known is the strings values (e.g "first_name", "last_name") <strong>on runtime only</strong>, therefore I cannot create any predefined classes (like usually used in fromJson() method). <br/><br/></p>
  
  <p>I have tried to create the following function (after I saw some examples online) and it didn't work:</p>
  
  <pre><code>public List&lt;Map&lt;String, Object&gt;&gt; fromJson(String jsonAsString) {
      final JsonElement jsonElement = this.jsonParser.parse(jsonAsString);
  
      List&lt;Map&lt;String, Object&gt;&gt; myList= new ArrayList&lt;Map&lt;String, Object&gt;&gt;();
      Type listType = TypeToken.get(myList.getClass()).getType();
      myList= (new Gson()).fromJson(jsonElement, listType);
  
      return myList;
  }   
  </code></pre>
  
  <p>The result of this function is a list (length == 2 in the above case) but instead of 2 maps i'm getting 2 Objects.<br/></p>
  
  <p>Any help?
  Thanks!</p>