MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / value

Function value

src/include/nlohmann/json.hpp:2246–2269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2244 string_t, typename std::decay<ValueType>::type >;
2245
2246 public:
2247 /// @brief access specified object element with default value
2248 /// @sa https://json.nlohmann.me/api/basic_json/value/
2249 template < class ValueType, detail::enable_if_t <
2250 !detail::is_transparent<object_comparator_t>::value
2251 && detail::is_getable<basic_json_t, ValueType>::value
2252 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
2253 ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
2254 {
2255 // value only works for objects
2256 if (JSON_HEDLEY_LIKELY(is_object()))
2257 {
2258 // If 'key' is found, return its value. Otherwise, return `default_value'.
2259 const auto it = find(key);
2260 if (it != end())
2261 {
2262 return it->template get<ValueType>();
2263 }
2264
2265 return default_value;
2266 }
2267
2268 JSON_THROW(type_error::create(306, detail::concat("cannot use value() with ", type_name()), this));
2269 }
2270
2271 /// @brief access specified object element with default value
2272 /// @sa https://json.nlohmann.me/api/basic_json/value/

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected