diff --git a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlWriter.java b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlWriter.java index c9cf7c7..75cd3bf 100644 --- a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlWriter.java +++ b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlWriter.java @@ -199,6 +199,9 @@ public class XmlWriter extends SerializeWriter implement private void beforeValue() throws IOException { switch (peek()) { case DOCUMENT, ARRAY, OBJECT_VALUE_WRAPPER -> {} + case OBJECT -> { + if (deferredName == null) throw new IllegalStateException("Name not set."); + } default -> throw new IllegalStateException("Nesting problem."); } }