1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-09 11:01:47 +03:00

fixed #45 (added count function for keys in objects)

This commit is contained in:
Niels
2015-03-22 19:07:43 +01:00
parent cf829ac2e8
commit f2957dc3bf
4 changed files with 94 additions and 3 deletions

View File

@ -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 //