com.transferwise.tasks.utils.JsonUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
package com.transferwise.tasks.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.transferwise.common.baseutils.ExceptionUtils;
public final class JsonUtils {
private JsonUtils() {
throw new AssertionError();
}
public static String toJson(ObjectMapper objectMapper, Object obj) {
return ExceptionUtils.doUnchecked(() -> objectMapper.writeValueAsString(obj));
}
public static T fromJson(ObjectMapper objectMapper, String st, Class type) {
return ExceptionUtils.doUnchecked(() -> objectMapper.readValue(st, type));
}
}