From 62ad140d1852ac6f90d16e4e03d168896f08d8a7 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Fri, 6 Mar 2015 12:35:58 -0600 Subject: [PATCH] rejectDupKeys --- src/lib_json/json_reader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index c79abdf..9ceaf38 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -1432,6 +1432,11 @@ bool OurReader::readObject(Token& tokenStart) { "Missing ':' after object member name", colon, tokenObjectEnd); } if (name.length() >= (1U<<30)) throw std::runtime_error("keylength >= 2^30"); + if (features_.rejectDupKeys_ && currentValue().isMember(name)) { + std::string msg = "Duplicate key: '" + name + "'"; + return addErrorAndRecover( + msg, tokenName, tokenObjectEnd); + } Value& value = currentValue()[name]; nodes_.push(&value); bool ok = readValue();