fixed #45 (added count function for keys in objects)
This commit is contained in:
parent
cf829ac2e8
commit
f2957dc3bf
4 changed files with 94 additions and 3 deletions
|
@ -1049,7 +1049,6 @@ class basic_json
|
|||
return m_value.object->operator[](key);
|
||||
}
|
||||
|
||||
|
||||
/// find an element in an object
|
||||
inline iterator find(typename object_t::key_type key)
|
||||
{
|
||||
|
@ -1076,6 +1075,13 @@ class basic_json
|
|||
return result;
|
||||
}
|
||||
|
||||
/// returns the number of occurrences of a key in an object
|
||||
inline size_type count(typename object_t::key_type key) const
|
||||
{
|
||||
// return 0 for all nonobject types
|
||||
return (m_type == value_t::object) ? m_value.object->count(key) : 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// iterators //
|
||||
|
|
|
@ -1049,7 +1049,6 @@ class basic_json
|
|||
return m_value.object->operator[](key);
|
||||
}
|
||||
|
||||
|
||||
/// find an element in an object
|
||||
inline iterator find(typename object_t::key_type key)
|
||||
{
|
||||
|
@ -1076,6 +1075,13 @@ class basic_json
|
|||
return result;
|
||||
}
|
||||
|
||||
/// returns the number of occurrences of a key in an object
|
||||
inline size_type count(typename object_t::key_type key) const
|
||||
{
|
||||
// return 0 for all nonobject types
|
||||
return (m_type == value_t::object) ? m_value.object->count(key) : 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// iterators //
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue