mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 18:10:27 +01:00
fix get() for embedded zeroes in key
This method had been overlooked.
This commit is contained in:
parent
d31151d150
commit
0fd2875a44
@ -404,15 +404,19 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
const Value& operator[](const CppTL::ConstString& key) const;
|
const Value& operator[](const CppTL::ConstString& key) const;
|
||||||
#endif
|
#endif
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
|
/// \note deep copy
|
||||||
Value get(const char* key, const Value& defaultValue) const;
|
Value get(const char* key, const Value& defaultValue) const;
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
|
/// \note deep copy
|
||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
Value get(const char* key, const char* end, const Value& defaultValue) const;
|
Value get(const char* key, const char* end, const Value& defaultValue) const;
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
|
/// \note deep copy
|
||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
Value get(const std::string& key, const Value& defaultValue) const;
|
Value get(const std::string& key, const Value& defaultValue) const;
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
|
/// \note deep copy
|
||||||
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
||||||
#endif
|
#endif
|
||||||
/// Most general and efficient version of isMember()const, get()const,
|
/// Most general and efficient version of isMember()const, get()const,
|
||||||
|
@ -1028,8 +1028,8 @@ Value& Value::append(const Value& value) { return (*this)[size()] = value; }
|
|||||||
|
|
||||||
Value Value::get(char const* key, char const* end, Value const& defaultValue) const
|
Value Value::get(char const* key, char const* end, Value const& defaultValue) const
|
||||||
{
|
{
|
||||||
const Value* value = &((*this)[key]);
|
Value const* found = find(key, end);
|
||||||
return value == &nullRef ? defaultValue : *value;
|
return !found ? defaultValue : *found;
|
||||||
}
|
}
|
||||||
Value Value::get(char const* key, Value const& defaultValue) const
|
Value Value::get(char const* key, Value const& defaultValue) const
|
||||||
{
|
{
|
||||||
@ -1104,7 +1104,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
|||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
Value Value::get(const CppTL::ConstString& key,
|
Value Value::get(const CppTL::ConstString& key,
|
||||||
const Value& defaultValue) const {
|
const Value& defaultValue) const {
|
||||||
return get(key.c_str(), defaultValue);
|
return get(key.c_str(), key.end_c_str(), defaultValue);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user