mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
add rejectDupKeys feature - not yet impld
This commit is contained in:
parent
cada3b951f
commit
527332d5d5
@ -320,6 +320,8 @@ public:
|
|||||||
- `"failIfExtra": false or true`
|
- `"failIfExtra": false or true`
|
||||||
- If true, `parse()` returns false when extra non-whitespace trails
|
- If true, `parse()` returns false when extra non-whitespace trails
|
||||||
the JSON value in the input string.
|
the JSON value in the input string.
|
||||||
|
- `"rejectDupKeys": false or true`
|
||||||
|
- If true, `parse()` returns false when a key is duplicated within an object.
|
||||||
|
|
||||||
You can examine 'settings_` yourself
|
You can examine 'settings_` yourself
|
||||||
to see the defaults. You can also write and read them just like any
|
to see the defaults. You can also write and read them just like any
|
||||||
|
@ -916,6 +916,7 @@ public:
|
|||||||
bool allowNumericKeys_;
|
bool allowNumericKeys_;
|
||||||
bool allowSingleQuotes_;
|
bool allowSingleQuotes_;
|
||||||
bool failIfExtra_;
|
bool failIfExtra_;
|
||||||
|
bool rejectDupKeys_;
|
||||||
int stackLimit_;
|
int stackLimit_;
|
||||||
}; // OurFeatures
|
}; // OurFeatures
|
||||||
|
|
||||||
@ -1896,6 +1897,7 @@ CharReader* CharReaderBuilder::newCharReader() const
|
|||||||
features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
|
features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
|
||||||
features.stackLimit_ = settings_["stackLimit"].asInt();
|
features.stackLimit_ = settings_["stackLimit"].asInt();
|
||||||
features.failIfExtra_ = settings_["failIfExtra"].asBool();
|
features.failIfExtra_ = settings_["failIfExtra"].asBool();
|
||||||
|
features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
|
||||||
return new OurCharReader(collectComments, features);
|
return new OurCharReader(collectComments, features);
|
||||||
}
|
}
|
||||||
static void getValidReaderKeys(std::set<std::string>* valid_keys)
|
static void getValidReaderKeys(std::set<std::string>* valid_keys)
|
||||||
@ -1909,6 +1911,7 @@ static void getValidReaderKeys(std::set<std::string>* valid_keys)
|
|||||||
valid_keys->insert("allowSingleQuotes");
|
valid_keys->insert("allowSingleQuotes");
|
||||||
valid_keys->insert("stackLimit");
|
valid_keys->insert("stackLimit");
|
||||||
valid_keys->insert("failIfExtra");
|
valid_keys->insert("failIfExtra");
|
||||||
|
valid_keys->insert("rejectDupKeys");
|
||||||
}
|
}
|
||||||
bool CharReaderBuilder::validate(Json::Value* invalid) const
|
bool CharReaderBuilder::validate(Json::Value* invalid) const
|
||||||
{
|
{
|
||||||
@ -1941,6 +1944,7 @@ void CharReaderBuilder::strictMode(Json::Value* settings)
|
|||||||
(*settings)["allowNumericKeys"] = false;
|
(*settings)["allowNumericKeys"] = false;
|
||||||
(*settings)["allowSingleQuotes"] = false;
|
(*settings)["allowSingleQuotes"] = false;
|
||||||
(*settings)["failIfExtra"] = true;
|
(*settings)["failIfExtra"] = true;
|
||||||
|
(*settings)["rejectDupKeys"] = true;
|
||||||
//! [CharReaderBuilderStrictMode]
|
//! [CharReaderBuilderStrictMode]
|
||||||
}
|
}
|
||||||
// static
|
// static
|
||||||
@ -1955,6 +1959,7 @@ void CharReaderBuilder::setDefaults(Json::Value* settings)
|
|||||||
(*settings)["allowSingleQuotes"] = false;
|
(*settings)["allowSingleQuotes"] = false;
|
||||||
(*settings)["stackLimit"] = 1000;
|
(*settings)["stackLimit"] = 1000;
|
||||||
(*settings)["failIfExtra"] = false;
|
(*settings)["failIfExtra"] = false;
|
||||||
|
(*settings)["rejectDupKeys"] = false;
|
||||||
//! [CharReaderBuilderDefaults]
|
//! [CharReaderBuilderDefaults]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user