Class ObjectMapperHelper

java.lang.Object
org.knowm.xchange.utils.ObjectMapperHelper

public class ObjectMapperHelper
extends Object
  • Method Details

    • readValue

      public static <T> T readValue​(URL src, Class<T> valueType) throws IOException
      Throws:
      IOException
    • readValue

      public static <T> T readValue​(String value, Class<T> valueType) throws IOException
      Throws:
      IOException
    • readValueStrict

      public static <T> T readValueStrict​(String value, Class<T> valueType) throws IOException
      Throws:
      IOException
    • toJSON

      public static <T> String toJSON​(T valueType)
    • toCompactJSON

      public static <T> String toCompactJSON​(T valueType)
    • viaJSON

      public static <T> T viaJSON​(T valueType) throws IOException
      Useful for testing. Performs a round trip via a JSON string allowing ser/deser to be tested andv erified.

      Note that this deliberately uses a very strict ObjectMapper since we need to be sure that the source object is fully recreated without errors.

      Type Parameters:
      T - The object type
      Parameters:
      valueType - The object to be converted
      Returns:
      A copy of the object performed via JSON.
      Throws:
      IOException - If there are deserialization issues.