1 # <small>nlohmann::basic_json::</small>count
4 template<typename KeyT>
5 size_type count(KeyT&& key) const;
8 Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
9 always be `0` (`key` was not found) or `1` (`key` was found).
11 ## Template parameters
14 : A type for an object key.
19 : key value of the element to count.
23 Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
27 Strong exception safety: if an exception occurs, the original value stays intact.
31 Logarithmic in the size of the JSON object.
35 This method always returns `0` when executed on a JSON type that is not an object.
41 The example shows how `count()` is used.
44 --8<-- "examples/count.cpp"
50 --8<-- "examples/count.output"
55 - Added in version 1.0.0.