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

com.transferwise.tasks.utils.JsonUtils Maven / Gradle / Ivy

The newest version!
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));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy