| 16158 | template<class ValueType, typename std::enable_if< |
| 16159 | std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0> |
| 16160 | ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const |
| 16161 | { |
| 16162 | // at only works for objects |
| 16163 | if (JSON_LIKELY(is_object())) |
| 16164 | { |
| 16165 | // if key is found, return value and given default value otherwise |
| 16166 | const auto it = find(key); |
| 16167 | if (it != end()) |
| 16168 | { |
| 16169 | return *it; |
| 16170 | } |
| 16171 | |
| 16172 | return default_value; |
| 16173 | } |
| 16174 | |
| 16175 | JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); |
| 16176 | } |
| 16177 | |
| 16178 | /*! |
| 16179 | @brief overload for a default value of type const char* |