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

deserialize from a compatible input

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename InputType&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
static
xref:nlohmann/basic_json-0c.adoc[basic&lowbar;json]
parse(
    InputType&& i,
    xref:nlohmann/basic_json-0c/parser_callback_t.adoc[parser&lowbar;callback&lowbar;t] cb = nullptr,
    bool const allow&lowbar;exceptions = true,
    bool const ignore&lowbar;comments = false,
    bool const ignore&lowbar;trailing&lowbar;commas = false);
----

== Return Value

deserialized JSON value, or a discarded value if `allow&lowbar;exceptions` is `false` and a parse error occurred

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *i*
| input to read the JSON value from
| *cb*
| a parser callback function of type xref:nlohmann/basic_json-0c/parser_callback_t.adoc[`parser&lowbar;callback&lowbar;t`] which is used to control the deserialization by filtering the parsed values
| *allow&lowbar;exceptions*
| whether to throw exceptions in case of a parse error
| *ignore&lowbar;comments*
| whether comments should be ignored and treated like whitespace (`true`) or yield a parse error (`false`)
| *ignore&lowbar;trailing&lowbar;commas*
| whether trailing commas in arrays and objects should be ignored (`true`) or yield a parse error (`false`)
|===


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