package org.ovirt.mobile.movirt.util; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; public final class JsonUtils { private static ObjectMapper objectMapper = new ObjectMapper(); public static String objectToString(Object object) { try { return objectMapper.writeValueAsString(object); } catch (JsonProcessingException e) { throw new RuntimeException("Serialization failed", e); } } public static <T> T stringToObject(String value, Class<T> clazz) { try { return objectMapper.readValue(value, clazz); } catch (IOException e) { throw new RuntimeException("Deserialization failed", e); } } }