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

li.rudin.mavenjs.core.JSON Maven / Gradle / Ivy

The newest version!
package li.rudin.mavenjs.core;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JSON
{
	
	private static final ObjectMapper mapper = new ObjectMapper();


	public static String toJSON(Object o) throws JsonProcessingException
	{
		return mapper.writeValueAsString(o);
	}
	
	public static  T toObject(String json, Class type) throws JsonParseException, JsonMappingException, IOException
	{
		return mapper.readValue(json, type);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy