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

io.baltoro.client.util.ObjectUtil Maven / Gradle / Ivy

There is a newer version: 4.0.12
Show newest version
package io.baltoro.client.util;

import com.fasterxml.jackson.databind.ObjectMapper;

public class ObjectUtil
{
	static ObjectMapper mappper = new ObjectMapper();
	

	public static byte[] toJason(Object obj) throws Exception
	{
		byte[] bytes = mappper.writeValueAsBytes(obj);
		return bytes;
	}

	
	public static  T toObject(Class clazz, byte[] bytes)
	{
		Object obj = null;
		try
		{
			obj = mappper.readValue(bytes, clazz);
		} 
		catch (Exception e)
		{
			System.out.println(new String(bytes));
			e.printStackTrace();
		}
		
		return (T)obj;
	}
		
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy