Package groovy.yaml

Class YamlSlurper

java.lang.Object
groovy.yaml.YamlSlurper

public class YamlSlurper extends Object
Represents a YAML parser
Since:
3.0.0
  • Constructor Details

    • YamlSlurper

      public YamlSlurper()
  • Method Details

    • parseText

      public Object parseText(String yaml)
      Parse the content of the specified yaml into a tree of Nodes.
      Parameters:
      yaml - the content of yaml
      Returns:
      the root node of the parsed tree of Nodes
    • parse

      public Object parse(Reader reader)
      Parse the content of the specified reader into a tree of Nodes.
      Parameters:
      reader - the reader of yaml
      Returns:
      the root node of the parsed tree of Nodes
    • parse

      public Object parse(InputStream stream)
      Parse the content of the specified reader into a tree of Nodes.
      Parameters:
      stream - the reader of yaml
      Returns:
      the root node of the parsed tree of Nodes
    • parse

      public Object parse(File file) throws IOException
      Parse the content of the specified file into a tree of Nodes.
      Parameters:
      file - the reader of yaml
      Returns:
      the root node of the parsed tree of Nodes
      Throws:
      IOException
    • parse

      public Object parse(Path path) throws IOException
      Parse the content of the specified path into a tree of Nodes.
      Parameters:
      path - the reader of yaml
      Returns:
      the root node of the parsed tree of Nodes
      Throws:
      IOException
    • parseTextAs

      public <T> T parseTextAs(Class<T> type, String yaml)
      Parse the content of the specified YAML text into a typed object using Jackson databinding. Supports @JsonProperty and @JsonFormat annotations for property mapping and type conversion.
      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      yaml - the content of YAML
      Returns:
      a typed object
      Since:
      6.0.0
    • parseAs

      public <T> T parseAs(Class<T> type, Reader reader)
      Parse YAML from a reader into a typed object.
      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      reader - the reader of YAML
      Returns:
      a typed object
      Since:
      6.0.0
    • parseAs

      public <T> T parseAs(Class<T> type, InputStream stream)
      Parse YAML from an input stream into a typed object.
      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      stream - the input stream of YAML
      Returns:
      a typed object
      Since:
      6.0.0
    • parseAs

      public <T> T parseAs(Class<T> type, File file) throws IOException
      Parse YAML from a file into a typed object.
      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      file - the YAML file
      Returns:
      a typed object
      Throws:
      IOException
      Since:
      6.0.0
    • parseAs

      public <T> T parseAs(Class<T> type, Path path) throws IOException
      Parse YAML from a path into a typed object.
      Type Parameters:
      T - the target type
      Parameters:
      type - the target type
      path - the path to the YAML file
      Returns:
      a typed object
      Throws:
      IOException
      Since:
      6.0.0