All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.unit.nva.auth.JsonConfig Maven / Gradle / Ivy

There is a newer version: 1.41.0
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy