[#nlohmann-basic_json-0c-value-0b]
= xref:nlohmann.adoc[nlohmann]::xref:nlohmann/basic_json-0c.adoc[basic&lowbar;json]::value
:relfileprefix: ../../
:mrdocs:

access specified object element with default value

== Synopsis

Declared in `&lt;nlohmann&sol;json&period;hpp&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class ValueType,
    class ReturnType = value&lowbar;return&lowbar;type&lt;ValueType&gt;::type&gt;
requires !detail&colon;&colon;is&lowbar;transparent&lt;object&lowbar;comparator&lowbar;t&gt;&colon;&colon;value
                   &amp;&amp; detail&colon;&colon;is&lowbar;getable&lt;basic&lowbar;json&lowbar;t, ReturnType&gt;&colon;&colon;value
                   &amp;&amp; !std&colon;&colon;is&lowbar;same&lt;value&lowbar;t, detail&colon;&colon;uncvref&lowbar;t&lt;ValueType&gt;&gt;&colon;&colon;value
ReturnType
value(
    object&lowbar;t::key&lowbar;type const& key,
    ValueType&& default&lowbar;value) const;
----

== Return Value

value at _key_ if found, otherwise _default&lowbar;value_

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| key of the element to access
| *default&lowbar;value*
| value to return if _key_ is not found
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
