Skip to content

Commit

Permalink
fix(java): more flexible json parser (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Aug 25, 2022
1 parent c576b29 commit b7edbea
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
import static com.fasterxml.jackson.core.JsonGenerator.Feature;

public class JSONBuilder {

Expand All @@ -19,8 +20,11 @@ public ObjectMapper build() {
ObjectMapper mapper = JsonMapper.builder().disable(MapperFeature.ALLOW_COERCION_OF_SCALARS).build();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, this.failOnUnknown);
mapper.enable(Feature.AUTO_CLOSE_JSON_CONTENT);
mapper.enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);
mapper.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
return mapper;
Expand Down

0 comments on commit b7edbea

Please sign in to comment.