2
0
mirror of https://github.com/boostorg/json.git synced 2026-01-19 04:12:14 +00:00

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.
This commit is contained in:
Leandro Freitas
2025-12-04 15:06:20 -05:00
parent 91b65160e2
commit 707a450ade
2 changed files with 26 additions and 1 deletions

View File

@@ -1052,7 +1052,7 @@ struct ignoring_handler
--array_depth_;
if( (array_depth_ + object_depth_) == 0 )
return parent_->signal_end(ec);
return parent_->signal_value(ec);
return true;
}

View File

@@ -73,6 +73,18 @@ private:
BOOST_DESCRIBE_CLASS(Z, (X), (), (), (d))
};
struct W
{
X x;
};
BOOST_DESCRIBE_STRUCT(W, (), (x))
bool operator==( W const& w1, W const& w2 )
{
return w1.x == w2.x;
}
BOOST_DEFINE_ENUM_CLASS(E, x, y, z)
namespace boost {
@@ -401,6 +413,19 @@ public:
jo["e7"] = false;
jo["e8"] = nullptr;
testParseIntoValue<X>(jo);
object const unexpected_jo{{"x", object{{"unexpectedArray", array{}},
{"unexpectedObject", object{}},
{"unexpectedString", "qwerty"},
{"unexpectedInt", 42},
{"unexpectedUint", ULONG_MAX},
{"unexpectedDouble", 2.71},
{"unexpectedBool", true},
{"unexpectedNull", nullptr},
{"a", 1},
{"b", 3.14f},
{"c", "hello"}}}};
testParseIntoValue<W>(unexpected_jo);
#endif
}