fix required member check for described structs in parse_into - #1182
fix required member check for described structs in parse_into#1182Ramya-9353 wants to merge 1 commit into
Conversation
|
An automated preview of the documentation is available at https://1182.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-08-06 10:38:51 UTC |
|
GCOVR code coverage report https://1182.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-08-06 10:55:20 UTC |
|
|
|
I will have to think a bit about this one. I'm not sure we should check for this, because non-unique keys are explicitly discouraged by the RFC. On the other hand, I see the value this adds. |
| handler_tuple<converting_handler, InnerHandlers> handlers_; | ||
| int inner_active_ = -1; | ||
| std::size_t activated_ = 0; | ||
| std::array<bool, mp11::mp_size<Dt>::value> seen_ = {}; |
There was a problem hiding this comment.
This should be an std::bitset instead.

Repro:
parse_intoa described struct whose members are all required, from{"a": 1, "a": 2, "a": 3}. It reports success, andbandckeep whatever the caller's object held. Same for{"a": 2}as the second element of[{"a": 1, "b": 1, "c": "one"}, {"a": 2}]parsed intostd::vector<X>.Cause:
activated_counts values signalled rather than distinct members, and is never cleared, so a repeated key stands in for a missing one, and each object in a sequence starts from the previous object's count.Fix: record which members have been set, and clear that record in
on_object_begin, the way the sequence handler already clears its container inon_array_begin.