diff --git a/include/rfl/yaml/Reader.hpp b/include/rfl/yaml/Reader.hpp index 4ab9e62ae..ea210e8a0 100644 --- a/include/rfl/yaml/Reader.hpp +++ b/include/rfl/yaml/Reader.hpp @@ -194,12 +194,19 @@ struct Reader { return Error("Recursive YAML alias detected."); } for (const auto& p : _obj.node_) { + std::string_view key; try { - const auto k = p.first.as(); - _object_reader.read(std::string_view(k), InputVarType(p.second)); - } catch (std::exception& e) { - continue; + if (p.first.IsScalar()) { + key = p.first.Scalar(); + } else if (p.first.IsNull()) { + key = "null"; + } else { + return Error("YAML mapping key must be a scalar."); + } + } catch (const std::exception& e) { + return Error(e.what()); } + _object_reader.read(key, InputVarType(p.second)); } return std::nullopt; }