Commit 49176d36 authored by Colin DAMON's avatar Colin DAMON
Browse files

Json configuration and tooling

parent 393f1f76
......@@ -60,6 +60,12 @@ management:
name: borestop
default-property-inclusion: non_empty
write-dates-as-timestamps: false
fail-on-unknown-properties: false
# The commented value for `active` can be replaced with valid Spring profiles to load.
# Otherwise, it will be filled in by maven when building the JAR file
package com.ippon.borestop.infrastructure.primay;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
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;
public final class TestJson {
private static final ObjectMapper jsonMapper = jsonMapper();
private TestJson() {}
public static ObjectMapper jsonMapper() {
return new ObjectMapper()
.registerModule(new JavaTimeModule())
.registerModule(new Jdk8Module())
public static <T> String writeAsString(T object) {
try {
return jsonMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new AssertionError("Error serializing object: " + e.getMessage(), e);
public static <T> T readFromJson(String json, Class<T> clazz) {
try {
return jsonMapper.readValue(json, clazz);
} catch (IOException e) {
throw new AssertionError("Error reading value from json: " + e.getMessage(), e);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment