no.unit.nva.auth.JsonConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of auth Show documentation
Show all versions of auth Show documentation
A commons library for the NVA project
package no.unit.nva.auth;
import static nva.commons.core.attempt.Try.attempt;
import com.fasterxml.jackson.jr.annotationsupport.JacksonAnnotationExtension;
import com.fasterxml.jackson.jr.ob.JSON;
import nva.commons.core.JacocoGenerated;
@JacocoGenerated
public final class JsonConfig {
private static final JSON objectMapper = JSON.builder().register(JacksonAnnotationExtension.std).build();
private JsonConfig() {
}
public static T beanFrom(Class type, String source) {
return attempt(() -> objectMapper.beanFrom(type, source)).orElseThrow();
}
public static String asString(T object) {
return attempt(() -> objectMapper.asString(object)).orElseThrow();
}
}