title: Jackson parsing JSON containing an array of objects and array of maps w/ dynamic keys
body: <p>I have json like this:</p>
  
  <pre><code>{
  
      "users":{
             "1234":{
                   "firstname":"Joe",
                   "lastname":"Smith"
             },
             "9876":{
                   "firstname":"Bob",
                   "lastname":"Anderson"
             }
      },
      "jobs":[
            {
                "id":"abc",
                "location":"store"
            },
            {
                "id":"def",
                "location":"factory"
            }
      ]
  }
  </code></pre>
  
  <p>I'm parsing this using Jackson and so I have been parsing responses using: readvalue(json, MyCustomClass.class)</p>
  
  <p>Where MyCustomClass looks like</p>
  
  <pre><code>public class MyCustomClass{
        @JsonProperty("jobs")
        ArrayList&lt;Job&gt; jobs;
  
        @JsonProperty("users")
        ArrayList&lt;UserMap&gt; usersMap;
  }
  </code></pre>
  
  <p>Now the jobs parse perfectly into Jobs objects but I can't get the users to parse since they have dynamic keys. I read about JsonAnyGetter/Setter and tried making the UserMap object map that maps a string -> User like:</p>
  
  <pre><code>public class UserMap {
  
  private HashMap&lt;String,User&gt; usersMap;
  
  
  @JsonAnySetter
  public void add(String key, User user){
      usersMap.put(key, user);
  }
  
  @JsonAnyGetter
  public Map&lt;String, User&gt; getUsersMap(){
      return usersMap;
  }
  
  
  }
  </code></pre>
  
  <p>but that doesn't work. I think I can do it with a TypeReference wrapper but I only can think of a way to do that if those maps were the only type I was getting back. Since I am getting different types back (users and jobs) is it possible to do this?</p>