Skip to content

fix required member check for described structs in parse_into - #1182

Open
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:parse-into-required-members
Open

fix required member check for described structs in parse_into#1182
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:parse-into-required-members

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

Repro: parse_into a described struct whose members are all required, from {"a": 1, "a": 2, "a": 3}. It reports success, and b and c keep whatever the caller's object held. Same for {"a": 2} as the second element of [{"a": 1, "b": 1, "c": "one"}, {"a": 2}] parsed into std::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 in on_array_begin.

@cppalliance-bot

Copy link
Copy Markdown

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

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://1182.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1182.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1182.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-08-06 10:55:20 UTC

@cppalliance-bot

Copy link
Copy Markdown

@grisumbras

Copy link
Copy Markdown
Member

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_ = {};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an std::bitset instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants