[#nlohmann-basic_json-0c-parse-08]
= 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"]
----
&lsqb;&lsqb;nodiscard, deprecated&rsqb;&rsqb;
static
xref:nlohmann/basic_json-0c.adoc[basic&lowbar;json]
parse(
    &sol;&ast; implementation-defined &ast;&sol;::span&lowbar;input&lowbar;adapter&& 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);
----

[WARNING]
====
https://en.cppreference.com/cpp/language/attributes/deprecated[Deprecated^]: Since 3&period;8&period;0&semi; use parse(ptr, ptr &plus; len). Use of this entity is allowed but discouraged.
====
== 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]#
