nlohmann::basic_json::accept

check if the input is valid JSON (iterator pair, or iterator+sentinel pair for C++20 ranges support)

Synopsis

Declared in <nlohmann/json.hpp>

template<
    typename IteratorType,
    typename SentinelType = IteratorType>
requires detail::can_compare_ne<IteratorType, SentinelType>::value
static
bool
accept(
    IteratorType first,
    SentinelType last,
    bool const ignore_comments = false,
    bool const ignore_trailing_commas = false);

Return Value

whether the input is valid JSON

Parameters

NameDescription
firstiterator to the start of the input
lastiterator to the end of the input, or a sentinel value comparable to first
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)