mirror of
https://github.com/nlohmann/json.git
synced 2026-10-12 09:27:13 +00:00
Report one-character non-numeric array indices like basic_json in the view
Develop's #5800 made basic_json report a JSON pointer array index such as "/a" as parse_error.109 instead of out_of_range.404, as longer ones were; the view's array_index() follows, with "-" and the empty token still unresolved. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+6
-2
No files matched your search
Generated
+3
-1
@@ -2551,7 +2551,9 @@ index_status array_index(const StringType& s, std::size_t& idx) noexcept
|
||||
{
|
||||
return index_status::leading_zero;
|
||||
}
|
||||
if (s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))
|
||||
// as basic_json: also a single character, but "-" and the empty token are
|
||||
// left to the conversion below and reported as unresolved
|
||||
if (!s.empty() && !(s.size() == 1 && s[0] == '-') && !(s[0] >= '0' && s[0] <= '9'))
|
||||
{
|
||||
return index_status::not_number;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user