MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / value

Function value

3rd/nlohmann_json/include/nlohmann/json.hpp:3989–4005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3987 detail::is_getable<basic_json_t, ValueType>::value
3988 && !std::is_same<value_t, ValueType>::value, int >::type = 0 >
3989 ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
3990 {
3991 // at only works for objects
3992 if (JSON_HEDLEY_LIKELY(is_object()))
3993 {
3994 // if key is found, return value and given default value otherwise
3995 const auto it = find(key);
3996 if (it != end())
3997 {
3998 return it->template get<ValueType>();
3999 }
4000
4001 return default_value;
4002 }
4003
4004 JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this));
4005 }
4006
4007 /*!
4008 @brief overload for a default value of type const char*

Calls 6

stringFunction · 0.85
is_objectFunction · 0.70
findFunction · 0.70
endFunction · 0.70
createFunction · 0.70
type_nameFunction · 0.70

Tested by 3

operator==Method · 0.40
operator>=Method · 0.40
operator==Method · 0.40