Skip to content
Merged
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
2 changes: 1 addition & 1 deletion include/boost/json/detail/value_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ value_to_impl(
return {system::in_place_error, ec};
}

if( !describe::enum_from_string(str->data(), val) )
if( !describe::enum_from_string(str->subview(), val) )
{
BOOST_JSON_FAIL(ec, error::unknown_name);
return {system::in_place_error, ec};
Expand Down
8 changes: 8 additions & 0 deletions test/value_to.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@ class value_to_test
BOOST_TEST_THROWS_WITH_LOCATION(
value_to<::value_to_test_ns::E1>( value("x"), ctx... ));

{
// an embedded null must not truncate the enumerator name
value const jv( string_view("a\0", 2) );
BOOST_TEST( jv.as_string().size() == 2 );
BOOST_TEST_THROWS_WITH_LOCATION(
value_to<::value_to_test_ns::E1>( jv, ctx... ));
}

{
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
value jv = {{"n", -78}, {"d", 0.125}};
Expand Down
Loading