From 7c97655f5943a5f2be9292384ac3925ddc41ce4f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Nov 2024 13:54:43 +0100 Subject: [PATCH] :recycle: allow to continue after parse error --- include/nlohmann/detail/input/parser.hpp | 2 ++ single_include/nlohmann/json.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 0c61305f8..16fcbb552 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -354,6 +354,7 @@ class parser } break; } + case token_type::end_of_input: { if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) @@ -371,6 +372,7 @@ class parser m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } + case token_type::uninitialized: case token_type::end_array: case token_type::end_object: diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index d9e6e80f7..cb7b272a8 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -12710,6 +12710,7 @@ class parser } break; } + case token_type::end_of_input: { if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1)) @@ -12727,6 +12728,7 @@ class parser m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr)); } + case token_type::uninitialized: case token_type::end_array: case token_type::end_object: