title: Hamcrest matcher comparing double value from JSON
body: <p>I'm using the Hamcrest <code>CoreMatcher</code> classes as part of <code>spring-test</code> integration tests. My JSON looks like:</p>
  
  <pre><code>{"data":[{"distanceInMiles":4,"id":"f97236ba-f4ef-4...
  </code></pre>
  
  <p>And my integration test looks like:</p>
  
  <pre><code>double miles = 4.0
  Activity a = new BasicActivity(miles);
  this.activityManager.add(a); // A mock activity manager (in-memory)
  ...
  this.mockMvc.perform(get("/").accept("application/json"))
      .andExpect(jsonPath("$.data[0].distanceInMiles", is(miles)))
  </code></pre>
  
  <p>However, the assertion fails:</p>
  
  <pre><code>java.lang.AssertionError: JSON path "$.data[0].distanceInMiles"
  Expected: is &lt;4.0&gt;
       but: was &lt;4&gt;
      at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
  </code></pre>
  
  <p>I know that there's a separate <code>IsCloseTo</code> matcher here: <a href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/number/IsCloseTo.html" rel="noreferrer">http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/number/IsCloseTo.html</a>, but using it like so:</p>
  
  <pre><code>.andExpect(jsonPath("$.data[0].distanceInMiles", closeTo(miles, 0)))
  </code></pre>
  
  <p>results in a strange error:</p>
  
  <pre><code>java.lang.AssertionError: JSON path "$.data[0].distanceInMiles"
  Expected: a numeric value within &lt;0.0&gt; of &lt;4.0&gt;
       but: was a java.lang.Integer (&lt;4&gt;)
      at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
  </code></pre>
  
  <p>I was hoping to avoid having to include some kind of error - I <em>want</em> the returned value to be exactly <code>4</code>, I just don't care how many trailing zeroes are included.</p>