title: How to modify spring/jackson JSON deserialisation
body: <p>I'm trying to figure out how to adjust the way spring/jackson convert a JSON string (stored in a file) into various POJOs. For example, if I have this JSON:</p>
  
  <pre><code>{
      "rates":{
          "EURUSD":5.4321,
          "USDHKD":1.2345
      }
  }
  </code></pre>
  
  <p>I actually want to get an instance of my 'Rates' class. Inside that I want a List containing each individual rate. </p>
  
  <p>In my spring config file I created this entry:</p>
  
  <pre><code>@Bean 
      public ObjectMapper jsonObjectMapper() {
          return new MappingJackson2HttpMessageConverter().getObjectMapper();
  }
  </code></pre>
  
  <p>And in my service class I did this:</p>
  
  <pre><code>@Autowired
  ObjectMapper jsonObjectMapper;
  
  public Rates currentRates() {
      Resource resource = this.ctx.getResource("classpath:stub/data/rates/Rates-01.json");
      return this.jsonObjectMapper.readValue(resource.getURL(), Rates.class);
  }
  </code></pre>
  
  <p>The problem is that I am trying to figure out how to take the Map containing the currencies as a single key, break those currencies in two and then create a RateEntry object containing the two currencies and the rate, before populating a list in the Rates class.</p>
  
  <p>I've been looking at Spring's Conversion Service with the idea to define a converter that maps the Map to a list. i.e. this signature: <code>Converter&lt;Map&lt;String, BigDecimal&gt;, List&lt;Rate&gt;&gt;</code>. However this is based on the assumption that the JSON is first converted to standard types before the conversion service is called. An assumption I now think is incorrect.</p>
  
  <p>So I'm now trying to figure out if I need to register some sort of custom ObjectMapper to handle reading directly from the JSON String data. But that sounds like over kill as I only want to adjust part of the object graph, and let the default converters handle the rest.</p>
  
  <p>Any pointers appreciated. Thanks. </p>