31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package dev.coph.nextusweb.server.json;
|
|
|
|
import tools.jackson.databind.ObjectMapper;
|
|
|
|
|
|
/**
|
|
* Holder for the application-wide Jackson {@link ObjectMapper}.
|
|
*
|
|
* <p>A single, pre-configured mapper instance is shared across the whole server because
|
|
* {@code ObjectMapper} is thread-safe once configured and is relatively expensive to build.
|
|
* Centralizing it here ensures every component (request parsing, response serialization,
|
|
* WebSocket payloads) uses identical serialization settings.</p>
|
|
*
|
|
* <p>This class is a static holder and cannot be instantiated.</p>
|
|
*/
|
|
public final class JsonMapper {
|
|
|
|
/**
|
|
* The shared, thread-safe Jackson mapper used throughout the server for all JSON reading
|
|
* and writing.
|
|
*/
|
|
public static final ObjectMapper MAPPER = tools.jackson.databind.json.JsonMapper.builder()
|
|
// .addModule(new JavaTimeModule())
|
|
.build();
|
|
|
|
/**
|
|
* Private constructor preventing instantiation of this static holder class.
|
|
*/
|
|
private JsonMapper() {}
|
|
}
|