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

io.descoped.dc.api.util.JsonParser Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package io.descoped.dc.api.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import java.io.InputStream;

public interface JsonParser {

    ObjectMapper mapper();

    ObjectNode createObjectNode();

    ArrayNode createArrayNode();

     T fromJson(InputStream source, Class clazz);

     T fromJson(String source, Class clazz);

    String toJSON(Object value);

    String toPrettyJSON(Object value);

    static JsonParser createJsonParser() {
        return new JsonParserImpl();
    }

    static JsonParser createJsonParser(ObjectMapper objectMapper) {
        return new JsonParserImpl(objectMapper);
    }

    static JsonParser createYamlParser() {
        return new YamlParserImpl();
    }

    static JsonParser createYamlParser(YAMLFactory yamlFactory) {
        return new YamlParserImpl(yamlFactory);
    }

    static JsonParser createYamlParser(ObjectMapper objectMapper) {
        return new YamlParserImpl(objectMapper);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy