| 20276 | detail::is_getable<basic_json_t, ValueType>::value |
| 20277 | && !std::is_same<value_t, ValueType>::value, int >::type = 0 > |
| 20278 | ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const |
| 20279 | { |
| 20280 | // at only works for objects |
| 20281 | if (JSON_HEDLEY_LIKELY(is_object())) |
| 20282 | { |
| 20283 | // if key is found, return value and given default value otherwise |
| 20284 | const auto it = find(key); |
| 20285 | if (it != end()) |
| 20286 | { |
| 20287 | return it->template get<ValueType>(); |
| 20288 | } |
| 20289 | |
| 20290 | return default_value; |
| 20291 | } |
| 20292 | |
| 20293 | JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()))); |
| 20294 | } |
| 20295 | |
| 20296 | /*! |
| 20297 | @brief overload for a default value of type const char* |