From ce8e2419ca98e9818387852cf487165d18489f9a Mon Sep 17 00:00:00 2001 From: jihuayu <8042833@qq.com> Date: Fri, 17 Nov 2023 19:34:15 +0800 Subject: [PATCH] update --- src/types/json.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/json.h b/src/types/json.h index 4f27ec03d4f..9df5f592748 100644 --- a/src/types/json.h +++ b/src/types/json.h @@ -188,7 +188,9 @@ struct JsonValue { value, path, [&insert_values, &result_count, index](const std::string & /*path*/, jsoncons::json &val) { if (val.is_array()) { auto len = static_cast(val.size()); - if (index >= len /*index > 0*/ || len + index < 0 /*index < 0*/) { + // When index > 0, we need index < len + // when index < 0, we need index >= -len. + if (index >= len || index < -len) { result_count.emplace_back(std::nullopt); return; }