Class ObjectMappers


  • public class ObjectMappers
    extends java.lang.Object
    A simple object mapper holder for using one single ObjectMapper across the whole project.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T fromJson​(@NonNull java.lang.String json, @NonNull java.lang.Class<T> c)
      Convert the specified YAML String to an object of the specified class, throwing an unchecked exception (RuntimeException) if conversion fails
      static <T> T fromYaml​(@NonNull java.lang.String yaml, @NonNull java.lang.Class<T> c)
      Convert the specified YAML String to an object of the specified class, throwing an unchecked exception (RuntimeException) if conversion fails
      static org.nd4j.shade.jackson.databind.ObjectMapper json()
      Get a single object mapper for use with reading and writing JSON
      static java.lang.String toJson​(@NonNull java.lang.Object o)
      Convert the specified object to a JSON String, throwing an unchecked exception (RuntimeException) if conversion fails
      static java.lang.String toYaml​(@NonNull java.lang.Object o)
      Convert the specified object to a YAML String, throwing an unchecked exception (RuntimeException) if conversion fails
      static org.nd4j.shade.jackson.databind.ObjectMapper yaml()
      Get a single object mapper for use with reading and writing YAML
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • json

        public static org.nd4j.shade.jackson.databind.ObjectMapper json()
        Get a single object mapper for use with reading and writing JSON
        Returns:
        JSON object mapper
      • yaml

        public static org.nd4j.shade.jackson.databind.ObjectMapper yaml()
        Get a single object mapper for use with reading and writing YAML
        Returns:
        YAML object mapper
      • toYaml

        public static java.lang.String toYaml​(@NonNull
                                              @NonNull java.lang.Object o)
        Convert the specified object to a YAML String, throwing an unchecked exception (RuntimeException) if conversion fails
        Parameters:
        o - Object
        Returns:
        Object as YAML
      • toJson

        public static java.lang.String toJson​(@NonNull
                                              @NonNull java.lang.Object o)
        Convert the specified object to a JSON String, throwing an unchecked exception (RuntimeException) if conversion fails
        Parameters:
        o - Object
        Returns:
        Object as JSON
      • fromYaml

        public static <T> T fromYaml​(@NonNull
                                     @NonNull java.lang.String yaml,
                                     @NonNull
                                     @NonNull java.lang.Class<T> c)
        Convert the specified YAML String to an object of the specified class, throwing an unchecked exception (RuntimeException) if conversion fails
        Parameters:
        yaml - YAML string
        c - Class for the object
        Returns:
        Object from YAML
      • fromJson

        public static <T> T fromJson​(@NonNull
                                     @NonNull java.lang.String json,
                                     @NonNull
                                     @NonNull java.lang.Class<T> c)
        Convert the specified YAML String to an object of the specified class, throwing an unchecked exception (RuntimeException) if conversion fails
        Parameters:
        json - JSON string
        c - Class for the object
        Returns:
        Object from JSON