diff --git a/include/boost/json/detail/parse_into.hpp b/include/boost/json/detail/parse_into.hpp index dc1ff2733..ff246c6e3 100644 --- a/include/boost/json/detail/parse_into.hpp +++ b/include/boost/json/detail/parse_into.hpp @@ -1602,7 +1602,7 @@ class converting_handler bool on_array_end( system::error_code& ec ) { - if( !inner_active_ ) + if( inner_active_ < 0 ) return signal_end(ec); BOOST_JSON_INVOKE_INNER( array_end_handler_event{}, ec ); diff --git a/test/parse_into.cpp b/test/parse_into.cpp index c6f8e9f2a..d3e0ec49f 100644 --- a/test/parse_into.cpp +++ b/test/parse_into.cpp @@ -491,6 +491,18 @@ class parse_into_test "five", std::map{ {"one", 1}, {"pi", 3.14} })); + // the closing bracket of an array that belongs to an alternative has to + // be handed to that alternative, not treated as the end of the array + // the variant itself is an element of + testParseInto< Variant< std::vector> > >( + std::vector>{ {1, 2}, {3} } ); + testParseInto< std::vector< Variant, int> > >( + { std::vector{1}, std::vector{2} } ); +#if defined(BOOST_DESCRIBE_CXX14) + testParseIntoErrors< Variant >( + error::exhausted_variants, object{ {"z", array{ array{0} }} } ); +#endif // BOOST_DESCRIBE_CXX14 + testParseIntoErrors< Variant >( error::exhausted_variants, "a" ); testParseIntoErrors< Variant >(