diff --git a/pom.xml b/pom.xml
index d012168..901fc6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
org.mongodb
bson
- 4.11.1
+ 5.0.0
true
diff --git a/src/main/java/org/javawebstack/abstractdata/AbstractElement.java b/src/main/java/org/javawebstack/abstractdata/AbstractElement.java
index a2a441d..2db30ca 100644
--- a/src/main/java/org/javawebstack/abstractdata/AbstractElement.java
+++ b/src/main/java/org/javawebstack/abstractdata/AbstractElement.java
@@ -120,7 +120,11 @@ default String toYaml() {
}
static AbstractElement fromYaml(String source, boolean singleRoot) {
- return new YamlParser().setSingleRoot(singleRoot).parse(source);
+ try {
+ return new YamlParser().setSingleRoot(singleRoot).parse(source);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
}
static AbstractElement fromYaml(String source) {
diff --git a/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlDumper.java b/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlDumper.java
index 4dd7f37..937540b 100644
--- a/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlDumper.java
+++ b/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlDumper.java
@@ -8,14 +8,14 @@ public class LegacyYamlDumper {
protected static String dump(AbstractElement e, boolean pretty) {
Yaml yaml;
+ DumperOptions options = new DumperOptions();
if (pretty) {
- DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
- yaml = new Yaml(options);
} else {
- yaml = new Yaml();
+ options.setPrettyFlow(false);
}
+ yaml = new Yaml(options);
return yaml.dump(e.toObject());
}
diff --git a/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlParser.java b/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlParser.java
index 24399ee..fe230f5 100644
--- a/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlParser.java
+++ b/src/main/java/org/javawebstack/abstractdata/yaml/LegacyYamlParser.java
@@ -1,25 +1,34 @@
package org.javawebstack.abstractdata.yaml;
import org.javawebstack.abstractdata.AbstractElement;
+import org.javawebstack.abstractdata.AbstractNull;
import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.parser.ParserException;
-import java.util.HashMap;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
public class LegacyYamlParser {
- protected static AbstractElement parse(String source, boolean singleRoot) {
- Yaml yaml = new Yaml();
- Object object = yaml.load(source);
- if (singleRoot && object instanceof List) {
- List