title: Parsing dynamically generated JSON object names with Jackson
body: <p>I'm attempting to deserialize some MediaWiki context from JSON using Jackson into POJOs. However, the problem is that one of the JSON object names is the integer ID value of the article, so using an annotation like <code>@JsonProperty</code> can't be used because the value is never constant.</p>
  
  <p>Here's some sample JSON to describe what I mean:</p>
  
  <p><code>http://en.wikipedia.org/w/api.php?action=query&amp;titles=Albert%20Einstein&amp;prop=info&amp;format=json&amp;indexpageids</code></p>
  
  <pre><code>{
      "query": {
          "pageids": [
              "736"
          ],
          "pages": {
              "736": {
                  "pageid": 736,
                  "ns": 0,
                  "title": "Albert Einstein",
                  "contentmodel": "wikitext",
                  "pagelanguage": "en",
                  "touched": "2014-01-05T03:14:23Z",
                  "lastrevid": 588780054,
                  "counter": "",
                  "length": 106159
              }
          }
      }
  }
  </code></pre>
  
  <p>(MediaWiki recommends adding the &amp;indexpageids parameter to assist with parsing, however I can't see how it would be useful to me.)</p>
  
  <p>I tried using the <code>@JsonAnyGetter</code> and <code>@JsonAnySetter</code> annotations as well but they don't appear to help, throwing the same exception <code>com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "736" (class WikipediaPages), not marked as ignorable (one known property: "wikipediaPage"])</code>.</p>
  
  <p>Thanks for any and all assistance.</p>
  
  <p>Edit: Here's what the relevant classes look like at the moment:</p>
  
  <pre><code>public class WikipediaPages {
  
      private Map&lt;String, WikipediaPage&gt; wikipediaPageMap = new HashMap&lt;String, WikipediaPage&gt;();
  
      public Map&lt;String, WikipediaPage&gt; getWikipediaPageMap() {
          return wikipediaPageMap;
      }
  
      public void setWikipediaPageMap(Map&lt;String, WikipediaPage&gt; wikipediaPageMap) {
          this.wikipediaPageMap = wikipediaPageMap;
      }
  }
  </code></pre>
  
  <p>I use a Jackson Mixin to apply annotations:</p>
  
  <pre><code>public interface WikipediaPagesMixIn {
  
      @JsonAnyGetter
      Map&lt;String, WikipediaPage&gt; getWikipediaPageMap();
  
      @JsonAnySetter
      void setWikipediaPageMap(Map&lt;String, WikipediaPage&gt; wikipediaPageMap);
  }
  </code></pre>
  
  <p>Edit 2: More code, as requested:</p>
  
  <pre><code>public class JacksonBuilder {
  
      private static ObjectMapper objectMapper;
  
      public static ObjectMapper getObjectMapper() {
          if(objectMapper == null) {
              objectMapper = new ObjectMapper();
              objectMapper.registerModule(new WikipediaModule());
          }
  
          return objectMapper;
      }
  }
  
  public class WikipediaModule extends SimpleModule {
  
      public WikipediaModule() {
          super("WikipediaModule", new Version(1, 0, 0, null, "net.ryanmorrison", "sentience"));
      }
  
      @Override
      public void setupModule(SetupContext setupContext) {
          setupContext.setMixInAnnotations(WikipediaPage.class, WikipediaPageMixIn.class);
          setupContext.setMixInAnnotations(WikipediaPages.class, WikipediaPagesMixIn.class);
          setupContext.setMixInAnnotations(WikipediaQuery.class, WikipediaQueryMixIn.class);
          setupContext.setMixInAnnotations(WikipediaResult.class, WikipediaResultMixIn.class);
      }
  }
  
  public class WikipediaResult {
  
      private WikipediaQuery wikipediaQuery;
  
      public WikipediaQuery getWikipediaQuery() {
          return wikipediaQuery;
      }
  
      public void setWikipediaQuery(WikipediaQuery wikipediaQuery) {
          this.wikipediaQuery = wikipediaQuery;
      }
  }
  
  public interface WikipediaResultMixIn {
  
      @JsonProperty("query")
      WikipediaQuery getWikipediaQuery();
  }
  </code></pre>