Skip to content

Commit 707a450

Browse files
committed
Fix ignoring_handler for arrays in nested described structs
When parsing unexpected fields containing arrays in described structs, signal_value instead of signal_end to avoid prematurely exiting the parent object context.
1 parent 91b6516 commit 707a450

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

include/boost/json/detail/parse_into.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ struct ignoring_handler
10521052
--array_depth_;
10531053

10541054
if( (array_depth_ + object_depth_) == 0 )
1055-
return parent_->signal_end(ec);
1055+
return parent_->signal_value(ec);
10561056
return true;
10571057
}
10581058

test/parse_into.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ struct Z : X
7373
BOOST_DESCRIBE_CLASS(Z, (X), (), (), (d))
7474
};
7575

76+
struct W
77+
{
78+
X x;
79+
};
80+
81+
BOOST_DESCRIBE_STRUCT(W, (), (x))
82+
83+
bool operator==( W const& w1, W const& w2 )
84+
{
85+
return w1.x == w2.x;
86+
}
87+
7688
BOOST_DEFINE_ENUM_CLASS(E, x, y, z)
7789

7890
namespace boost {
@@ -401,6 +413,19 @@ class parse_into_test
401413
jo["e7"] = false;
402414
jo["e8"] = nullptr;
403415
testParseIntoValue<X>(jo);
416+
417+
object const unexpected_jo{{"x", object{{"unexpectedArray", array{}},
418+
{"unexpectedObject", object{}},
419+
{"unexpectedString", "qwerty"},
420+
{"unexpectedInt", 42},
421+
{"unexpectedUint", ULONG_MAX},
422+
{"unexpectedDouble", 2.71},
423+
{"unexpectedBool", true},
424+
{"unexpectedNull", nullptr},
425+
{"a", 1},
426+
{"b", 3.14f},
427+
{"c", "hello"}}}};
428+
testParseIntoValue<W>(unexpected_jo);
404429
#endif
405430
}
406431

0 commit comments

Comments
 (0)