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

prompto.reader.JSONReader Maven / Gradle / Ivy

There is a newer version: 0.1.57
Show newest version
package prompto.reader;

import java.io.IOException;
import java.io.InputStream;

import prompto.intrinsic.PromptoConverter;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public abstract class JSONReader {
	
	public static Object read(String json) throws IOException {
		try {
			JsonNode node = new ObjectMapper().readTree(json);
			return PromptoConverter.nodeToPrompto(node);
		} catch(RuntimeException e) {
			throw new IOException(e.getMessage());
		}
	}

	public static Object read(InputStream input) throws IOException {
		try {
			JsonNode node = new ObjectMapper().readTree(input);
			return PromptoConverter.nodeToPrompto(node);
		} catch(RuntimeException e) {
			throw new IOException(e.getMessage());
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy