package eu.eudat.migration.utils; import com.fasterxml.jackson.databind.ObjectMapper; import javax.persistence.AttributeConverter; import java.util.Map; public class JsonTypeConverter implements AttributeConverter, String> { ObjectMapper objectMapper = new ObjectMapper(); @Override public String convertToDatabaseColumn(Map customerInfo) { try { return objectMapper.writeValueAsString(customerInfo); } catch (Exception e) { return null; } } @Override public Map convertToEntityAttribute(String customerInfoJSON) { try { return objectMapper.readValue(customerInfoJSON, Map.class); } catch (Exception e) { return null; } } }