From 97680827b8f5a7c287ad95f819bddf582b3a1d54 Mon Sep 17 00:00:00 2001 From: Enrico Lumetti Date: Mon, 20 Jun 2016 16:59:32 +0200 Subject: [PATCH] Fix JSON integer parsing --- src/json_ui.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/json_ui.cc b/src/json_ui.cc index 53da6ee7..fd234154 100644 --- a/src/json_ui.cc +++ b/src/json_ui.cc @@ -261,7 +261,7 @@ parse_json(const char* pos, const char* end) { auto digit_end = pos; skip_while(digit_end, end, is_digit); - return Result{ Value{str_to_int({pos, end})}, digit_end }; + return Result{ Value{str_to_int({pos, digit_end})}, digit_end }; } if (end - pos > 4 and StringView{pos, pos+4} == "true") return Result{ Value{true}, pos+4 }; @@ -461,6 +461,12 @@ UnitTest test_json_parser{[]() kak_assert(value); } + { + auto value = std::get<0>(parse_json("[10,20]")); + kak_assert(value and value.is_a()); + kak_assert(value.as().at(1).as() == 20); + } + { auto value = std::get<0>(parse_json("{}")); kak_assert(value and value.is_a());