Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/boost/json/detail/parse_into.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ class converting_handler<variant_conversion_tag, T, P>

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 );
Expand Down Expand Up @@ -1864,10 +1864,14 @@ class into_handler
return true;
}

// LCOV_EXCL_START
// the top handler is never inside an array, so nested handlers have no
// array end to forward to it
bool signal_end(system::error_code&)
{
return true;
}
// LCOV_EXCL_STOP

bool on_document_begin( system::error_code& )
{
Expand Down
11 changes: 11 additions & 0 deletions test/parse_into.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <boost/json/value_to.hpp>
#include <boost/describe.hpp>

#include <array>
#include <climits>
#include <map>

Expand Down Expand Up @@ -479,6 +480,16 @@ class parse_into_test
testParseInto< std::vector< Variant<int, std::string> > >(
{1, 2, 3, "four", 5, "six", "seven", 8});

// an array-like first alternative nested in a composite
testParseInto< std::vector< Variant<std::vector<int>, int> > >(
{ std::vector<int>{1}, 2 } );
testParseInto< std::map<std::string, Variant<std::vector<int>, int> > >(
{ { "a", std::vector<int>{1, 2} }, { "b", 3 } } );

// an incomplete array must not satisfy a fixed-size alternative
testParseIntoErrors< Variant< std::array<int, 3> > >(
error::exhausted_variants, {1, 2} );

using V = Variant<
std::vector< int >,
std::tuple< int, std::string, std::map<std::string, int> >,
Expand Down
Loading