Skip to content

Commit

Permalink
#468 USE_BIG_DECIMAL_FOR_FLOATS test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Feb 9, 2022
1 parent bd65947 commit 431d07f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.time.Instant;

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;

class Jackson2ConfigTest {
Expand All @@ -33,6 +34,12 @@ void testSerializeTime2() {
assertThatJson(new Bean()).isEqualTo(new Bean());
}

@Test
void assertSame() {
String s = "{ \"a\": 0.0 }";
assertJsonEquals(s, s);
}

public static class Bean {
private final Instant time = Instant.parse("2019-01-11T18:12:00Z");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package net.javacrumbs.jsonunit.test.jackson2config;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
Expand All @@ -30,11 +31,13 @@ public class Java8ObjectMapperProvider implements Jackson2ObjectMapperProvider {
public Java8ObjectMapperProvider() {
mapper = new ObjectMapper().registerModule(new JavaTimeModule());
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);

lenientMapper = new ObjectMapper().registerModule(new JavaTimeModule());
lenientMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
lenientMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
lenientMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
lenientMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
}

@Override
Expand Down

0 comments on commit 431d07f

Please sign in to comment.