mirror of
https://github.com/nlohmann/json.git
synced 2026-10-05 14:10:31 +00:00
Merge remote-tracking branch 'origin/develop' into HEAD
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -132,15 +132,15 @@ class binary_reader
|
||||
|
||||
@param[in] adapter input adapter to read from
|
||||
@param[in] format the binary format to parse
|
||||
@param[in] error_handler how to treat text strings and object keys that
|
||||
@param[in] error_handler_ how to treat text strings and object keys that
|
||||
are not well-formed UTF-8; none of the supported formats
|
||||
requires a decoder to reject those, so the default is to
|
||||
@ref error_handler_t::keep them unchanged, as every binary
|
||||
reader did before this parameter existed
|
||||
*/
|
||||
explicit binary_reader(InputAdapterType&& adapter, const input_format_t format = input_format_t::json,
|
||||
const error_handler_t error_handler = error_handler_t::keep) noexcept
|
||||
: ia(std::move(adapter)), input_format(format), error_handler(error_handler)
|
||||
const error_handler_t error_handler_ = error_handler_t::keep) noexcept
|
||||
: ia(std::move(adapter)), input_format(format), error_handler(error_handler_)
|
||||
{
|
||||
(void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
|
||||
}
|
||||
|
||||
@@ -322,6 +322,8 @@ class json_pointer
|
||||
typename BasicJsonType::size_type idx{};
|
||||
switch (parse_array_index<BasicJsonType>(s, idx))
|
||||
{
|
||||
// the branches differ in their messages, not after JSON_THROW's expansion
|
||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||
case array_index_status::leading_zero:
|
||||
JSON_THROW(detail::parse_error::create(106, 0, detail::concat("array index '", s, "' must not begin with '0'"), nullptr));
|
||||
case array_index_status::not_a_number:
|
||||
@@ -685,6 +687,8 @@ class json_pointer
|
||||
typename BasicJsonType::size_type idx{};
|
||||
switch (parse_array_index<BasicJsonType>(reference_token, idx))
|
||||
{
|
||||
// the branches differ in their messages, not after JSON_THROW's expansion
|
||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||
case array_index_status::leading_zero:
|
||||
JSON_THROW(detail::parse_error::create(106, 0, detail::concat("array index '", reference_token, "' must not begin with '0'"), nullptr));
|
||||
case array_index_status::not_a_number:
|
||||
|
||||
@@ -2260,18 +2260,18 @@ class binary_writer
|
||||
switch (error_handler)
|
||||
{
|
||||
case error_handler_t::keep:
|
||||
return s;
|
||||
return s; // NOLINT(bugprone-return-const-ref-from-parameter): callers pass lvalues that outlive the call
|
||||
|
||||
case error_handler_t::strict:
|
||||
check_utf8(s, context);
|
||||
return s;
|
||||
return s; // NOLINT(bugprone-return-const-ref-from-parameter): callers pass lvalues that outlive the call
|
||||
|
||||
case error_handler_t::replace:
|
||||
case error_handler_t::ignore:
|
||||
default:
|
||||
if (is_valid_utf8(s))
|
||||
{
|
||||
return s;
|
||||
return s; // NOLINT(bugprone-return-const-ref-from-parameter): callers pass lvalues that outlive the call
|
||||
}
|
||||
storage = sanitize_utf8(s, error_handler);
|
||||
return storage;
|
||||
|
||||
@@ -706,6 +706,11 @@ class serializer
|
||||
@a ensure_ascii is a template parameter here so that the branch on it is
|
||||
resolved once, outside the loop; see @ref dump_escaped.
|
||||
*/
|
||||
#ifdef JSON_HEDLEY_MSVC_VERSION
|
||||
#pragma warning(push)
|
||||
// EnsureAscii is a template parameter; C++11 has no if constexpr
|
||||
#pragma warning(disable : 4127) // conditional expression is constant
|
||||
#endif
|
||||
template<bool EnsureAscii>
|
||||
void dump_escaped_impl(const string_t& s)
|
||||
{
|
||||
@@ -1055,6 +1060,9 @@ class serializer
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef JSON_HEDLEY_MSVC_VERSION
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
private:
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user