Assertion failure when serializing array with JSON_DIAGNOSTICS set #2926
Closed
Description
I fixed the issue and also found some more member functions that could have triggered the assertion, see #2866. Feedback welcome!
@nlohmann Do you also need to track capacity in the external construct
functions, e.g.
template < typename BasicJsonType, typename CompatibleArrayType,
enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
int > = 0 >
static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
?
I'm getting a very hard to reproduce write access violation with JSON_DIAGNOSTICS 1
when implicitly serializing an std::array
of serializable structs. Can't get a minimal example to throw it though, not sure why. It seems related to this bug though.
Thrown here:
One stack up:
Edit: It's actually an array of std::optional
s with a custom serializer per https://nlohmann.github.io/json/features/arbitrary_types/#how-do-i-convert-third-party-types. This works fine with JSON_DIAGNOSTICS 0
.
Originally posted by @MHebes in #2838 (comment)