title: How to customize Jackson ObjectMapper to allow NaN in Spring Boot 2.0?
body: <p>Moving this here from <a href="https://github.com/spring-projects/spring-boot/issues/10500" rel="nofollow noreferrer">GitHub</a> as the Spring team only uses GitHub issues for bugs and feature requests.</p>
  <p>Per the Spring Boot <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-the-jackson-objectmapper" rel="nofollow noreferrer">documentation</a>, it should be possible to customize the Jackson <code>ObjectMapper</code> using environment properties (e.g. in <code>application.properties</code>) such as <code>spring.jackson.parser.&lt;feature_name&gt;</code> as long as you're not defining your own <code>ObjectMapper</code> bean.</p>
  <p>I need to activate the <code>ALLOW_NON_NUMERIC_NUMBERS</code> parser features as I'm getting (strictly speaking invalid) JSON with <code>NaN</code> values for floating point fields that I want Jackson to map to <code>java.lang.Double.NaN</code> in Java.</p>
  <p>So in my <code>application.properties</code> I've added <code>spring.jackson.parser.ALLOW_NON_NUMERIC_NUMBERS=true</code> and I can see this is being picked up:</p>
  <ul>
  <li>Spring Boot's <code>JacksonAutoConfiguration</code> is creating an <code>Jackson2ObjectMapperBuilder</code></li>
  <li><code>Jackson2ObjectMapperBuilder</code>'s  <code>StandardJackson2ObjectMapperBuilderCustomizer</code> is picking up my <code>spring.jackson.parser.ALLOW_NON_NUMERIC_NUMBERS=true</code> property and adding it to its <code>features</code> map</li>
  <li><code>Jackson2ObjectMapperBuilder</code>'s <code>build()</code> method is eventually calling <code>configureFeature</code> which results in the mask value of the <code>ALLOW_NON_NUMERIC_NUMBERS</code> feature (512) being added to the <code>_parserFeatures</code> value in the <code>JsonFactory</code> of the <code>ObjectMapper</code></li>
  <li>the <code>ObjectMapper</code> being injected in my bean using <code>@Autowired</code> also has the <code>ALLOW_NON_NUMERIC_NUMBERS</code> feature enabled</li>
  </ul>
  <p>What's unclear is why I'm still getting the following Jackson error when parsing JSON that has the <code>NaN</code> value for a floating point field:
  <code>JSON decoding error: Character N is neither a decimal digit number, decimal point, nor &quot;e&quot; notation exponential mark.</code></p>
  <p>I'm debugging now so I'll probably end up answering my own question. The above detail is to possibly help people coming from <a href="https://github.com/spring-projects/spring-boot/issues/10500" rel="nofollow noreferrer">the GitHub issue</a> to find a thread to pull on in case their feature flags aren't being applied.</p>