Package ai.konduit.serving.util
Class ObjectMappers
- java.lang.Object
-
- ai.konduit.serving.util.ObjectMappers
-
public class ObjectMappers extends java.lang.ObjectA simple object mapper holder for using one singleObjectMapperacross the whole project.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfromJson(@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 failsstatic <T> TfromYaml(@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 failsstatic org.nd4j.shade.jackson.databind.ObjectMapperjson()Get a single object mapper for use with reading and writing JSONstatic java.lang.StringtoJson(@NonNull java.lang.Object o)Convert the specified object to a JSON String, throwing an unchecked exception (RuntimeException) if conversion failsstatic java.lang.StringtoYaml(@NonNull java.lang.Object o)Convert the specified object to a YAML String, throwing an unchecked exception (RuntimeException) if conversion failsstatic org.nd4j.shade.jackson.databind.ObjectMapperyaml()Get a single object mapper for use with reading and writing YAML
-
-
-
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 stringc- 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 stringc- Class for the object- Returns:
- Object from JSON
-
-