diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 87483da..9818b5b 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -467,7 +467,7 @@ bool Reader::readObject(Token& token) { Value numberName; if (!decodeNumber(tokenName, numberName)) return recoverFromError(tokenObjectEnd); - name = String(numberName.asCString()); + name = numberName.asString(); } else { break; } diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 6f4bbde..6f52304 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -2648,6 +2648,10 @@ struct ReaderTest : JsonTest::TestCase { new Json::Reader(Json::Features{}.strictMode())); } + void setFeatures(Json::Features& features) { + reader = std::unique_ptr(new Json::Reader(features)); + } + void checkStructuredErrors( const std::vector& actual, const std::vector& expected) { @@ -2851,6 +2855,13 @@ JSONTEST_FIXTURE_LOCAL(ReaderTest, pushErrorTest) { "See Line 1, Column 14 for detail.\n"); } +JSONTEST_FIXTURE_LOCAL(ReaderTest, allowNumericKeysTest) { + Json::Features features; + features.allowNumericKeys_ = true; + setFeatures(features); + checkParse(R"({ 123 : "abc" })"); +} + struct CharReaderTest : JsonTest::TestCase {}; JSONTEST_FIXTURE_LOCAL(CharReaderTest, parseWithNoErrors) {