nlohmann::basic_json::count

returns the number of occurrences of a key in a JSON object

Synopsis

Declared in <nlohmann/json.hpp>

template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
size_type
count(KeyType&& key) const;

Return Value

number of occurrences of the key (0 or 1 for a JSON object, 0 for all other types)

Parameters

NameDescription
keykey to count occurrences of