title: Jackson-databind 2.5 converting float to int
body: <p>What is the alternate of DeserializationFeature.ACCEPT_FLOAT_AS_INT in <strong>jackson-databind</strong> <strong>2.5</strong>, as this deserialization configuration is NOT available in <strong>2.5</strong> (its available since <strong>2.6</strong>)</p>
  
  <p>Our application is using jackson-databind <strong>2.5</strong>, in which we noticed that float is being converted to int.</p>
  
  <p>We though that we will need to disable value conversions, coercion. But as we are using jackson 2.5, there is <strong>NO</strong> <em>DeserializationFeature.ACCEPT_FLOAT_AS_INT</em></p>
  
  <p>How to disable this float to int conversion in 2.5? We expect that the user should be getting the data validation exception if he is providing float, instead on int, in "age".</p>
  
  <p>Following is the sample POJO</p>
  
  <pre><code>public class User {
  
      private String name;
      private Integer age;
  
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public int getAge() {
          return age;
      }
      public void setAge(int age) {
          this.age = age;
      }
  
  }
  </code></pre>
  
  <p>This is the test code (using jackson-databind 2.5):</p>
  
  <pre><code>import com.fasterxml.jackson.core.JsonParseException;
  import com.fasterxml.jackson.databind.JsonMappingException;
  import com.fasterxml.jackson.databind.ObjectMapper;
  
  public class TestConvert {
  
      public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
  
          ObjectMapper mapper = new ObjectMapper();
          String json = "{\"name\" : \"foobar\", \"age\" : 2.99}";
  
          //JSON from file to Object
          User user = mapper.readValue(json, User.class);
  
          //Object to JSON in String
          String jsonInString = mapper.writeValueAsString(user);
          System.out.println(jsonInString);
  
  
      }
  
  }
  </code></pre>
  
  <p>Output of above test code is:</p>
  
  <p>{"name":"foobar","age":2}</p>