Skip to content

Commit b7edbea

Browse files
authored
fix(java): more flexible json parser (#954)
1 parent c576b29 commit b7edbea

File tree

1 file changed

+4
-0
lines changed
  • clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils

1 file changed

+4
-0
lines changed

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/JSONBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.*;
44
import com.fasterxml.jackson.databind.*;
55
import com.fasterxml.jackson.databind.json.JsonMapper;
6+
import static com.fasterxml.jackson.core.JsonGenerator.Feature;
67

78
public class JSONBuilder {
89

@@ -19,8 +20,11 @@ public ObjectMapper build() {
1920
ObjectMapper mapper = JsonMapper.builder().disable(MapperFeature.ALLOW_COERCION_OF_SCALARS).build();
2021
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
2122
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, this.failOnUnknown);
23+
mapper.enable(Feature.AUTO_CLOSE_JSON_CONTENT);
2224
mapper.enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
2325
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
26+
mapper.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);
27+
mapper.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
2428
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
2529
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
2630
return mapper;

0 commit comments

Comments
 (0)