Class JsonSupport

java.lang.Object
com.codebarrel.api.JsonSupport

public class JsonSupport extends Object
Helper class to aid with JSON serialization/deserialization.
  • Constructor Details

    • JsonSupport

      public JsonSupport()
  • Method Details

    • toJsonBytes

      public static byte[] toJsonBytes(Object json)
    • toJsonStream

      public static void toJsonStream(Object json, OutputStream out)
    • convertValue

      public static <T> T convertValue(Object input, Class<T> type)
    • convertValue

      public static <T> T convertValue(Object input, com.fasterxml.jackson.core.type.TypeReference<?> typeRef)
    • toJsonString

      public static String toJsonString(Object json)
    • toObject

      public static <T> T toObject(String in, com.fasterxml.jackson.core.type.TypeReference<?> typeRef)
    • toObject

      public static <T> T toObject(byte[] bytes, Class<T> type)
    • toObject

      public static <T> T toObject(InputStream in, Class<T> type)
    • toJsonNode

      public static com.fasterxml.jackson.databind.JsonNode toJsonNode(String in)
    • toObject

      public static <T> T toObject(String in, Class<T> type) throws RuntimeException
      Converts a JSON string to a specific type. Callers should consider catching RuntimeException or JsonParseException since this will be thrown if the JSON is not parseable
      Throws:
      RuntimeException
    • toList

      public static <T> List<T> toList(String in, Class<T> type)