Class YamlUtils

java.lang.Object
land.oras.utils.YamlUtils

@NullMarked public final class YamlUtils extends Object
Utility class for YAML operations. Use Jackson 3 internally for YAML operations
  • Method Details

    • toYaml

      public static String toYaml(Object object)
      Convert an object to a YAML string
      Parameters:
      object - The object to convert
      Returns:
      The YAML string
    • fromYaml

      public static <T> T fromYaml(String yaml, Class<T> clazz)
      Convert a YAML string to an object
      Type Parameters:
      T - The type of the object
      Parameters:
      yaml - The YAML string
      clazz - The class of the object
      Returns:
      The object
    • fromYaml

      public static <T> T fromYaml(Path path, Class<T> clazz)
      Read a YAML file and convert its contents to an object. The file at the given path is read as UTF-8 YAML and deserialized into the specified type.
      Type Parameters:
      T - The type of the object
      Parameters:
      path - The path to the YAML file
      clazz - The class of the object
      Returns:
      The object deserialized from the YAML file