blob: d54c58ca4fa4e26c6f07f56bc67a0cd7009a196c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.restapi;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonFactoryBuilder;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
/**
* Default Jackson {@link ObjectMapper} instance shared by {@link com.yahoo.restapi}.
*
* @author bjorncs
*/
class JacksonJsonMapper {
static final ObjectMapper instance = new ObjectMapper(createFactory())
.registerModule(new JavaTimeModule())
.registerModule(new Jdk8Module())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
private JacksonJsonMapper() {}
private static JsonFactory createFactory() {
return new JsonFactoryBuilder()
.streamReadConstraints(StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build())
.build();
}
}
|