nlohmann::basic_json::parse

deserialize from a compatible input

Synopsis

Declared in <nlohmann/json.hpp>

template<typename InputType>
[[nodiscard]]
static
basic_json
parse(
    InputType&& i,
    parser_callback_t cb = nullptr,
    bool const allow_exceptions = true,
    bool const ignore_comments = false,
    bool const ignore_trailing_commas = false);

Return Value

deserialized JSON value, or a discarded value if allow_exceptions is false and a parse error occurred

NOTE

The return value should not be discarded.

Parameters

NameDescription
iinput to read the JSON value from
cba parser callback function of type parser_callback_t which is used to control the deserialization by filtering the parsed values
allow_exceptionswhether to throw exceptions in case of a parse error
ignore_commentswhether comments should be ignored and treated like whitespace (true) or yield a parse error (false)
ignore_trailing_commaswhether trailing commas in arrays and objects should be ignored (true) or yield a parse error (false)