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