From fd37016cf85075303de74bab9c61e5d13bf71f64 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 23 Feb 2023 01:15:28 +0300 Subject: [PATCH] Allow trailing comma --- json11.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/json11.cpp b/json11.cpp index ae37004..e5e6d03 100644 --- a/json11.cpp +++ b/json11.cpp @@ -769,6 +769,8 @@ struct JsonParser final { return fail("expected ',' in object, got " + esc(ch)); ch = get_next_token(); + if (ch == '}') + break; } return data; } @@ -792,6 +794,8 @@ struct JsonParser final { return fail("expected ',' in list, got " + esc(ch)); ch = get_next_token(); + if (ch == ']') + break; (void)ch; } return data;