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 4 commits 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-13 06:48:59 UTC |
|
GCOVR code coverage report https://1182.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-08-13 07:00:22 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. |
|
On the RFC point: fair, though the patch does not actually reject duplicate keys as such. A document with repeated keys still parses so long as every required member is supplied somewhere; a repeat just no longer counts as a second distinct member. The other half of the bug also triggers with entirely unique keys: |
|
|
|
|
|
Also, please rebase on current develop, so that CI stops failing. |
bff5000 to
9e9458f
Compare
|
Rebased onto current develop. |
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1182 +/- ##
========================================
Coverage 93.91% 93.91%
========================================
Files 91 91
Lines 9288 9290 +2
========================================
+ Hits 8723 8725 +2
Misses 565 565
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|




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.