diff --git a/src/main/java/com/amihaiemil/eoyaml/YamlInput.java b/src/main/java/com/amihaiemil/eoyaml/YamlInput.java index b0e07e30..297888b3 100644 --- a/src/main/java/com/amihaiemil/eoyaml/YamlInput.java +++ b/src/main/java/com/amihaiemil/eoyaml/YamlInput.java @@ -99,4 +99,20 @@ public interface YamlInput { * @throws IOException if the input cannot be read for some reason */ Scalar readLiteralBlockScalar() throws IOException; + + /** + * Read the given input as a generic YamlNode. + * @return YamlNode. + * @throws IOException If something goes wrong. + */ + default YamlNode readYamlNode() throws IOException { + final YamlNode document; + final YamlStream stream = this.readYamlStream(); + if(stream.values().size() == 1) { + document = stream.iterator().next(); + } else { + document = stream; + } + return document; + } }