diff --git a/src/jsrs_parser.cc b/src/jsrs_parser.cc index baa24e2..d10255e 100644 --- a/src/jsrs_parser.cc +++ b/src/jsrs_parser.cc @@ -721,6 +721,7 @@ MaybeLocal ParseObject(Isolate* isolate, bool key_mode = true; *size = end - begin; MaybeLocal current_key; + MaybeLocal current_numeric_key; MaybeLocal current_value; size_t current_length = 0; auto result = Object::New(isolate); @@ -734,10 +735,16 @@ MaybeLocal ParseObject(Isolate* isolate, has_ended = true; break; } - current_key = ParseKeyInObject(isolate, - begin + i, - end, - ¤t_length); + if (!isdigit(begin[i])) { + current_key = ParseKeyInObject(isolate, begin + i, end, + ¤t_length); + } else { + current_numeric_key = ParseNumber(isolate, begin + i, end, + ¤t_length); + current_key = current_numeric_key.IsEmpty() ? MaybeLocal() : + current_numeric_key.ToLocalChecked()->ToString( + isolate->GetCurrentContext()); + } if (current_key.IsEmpty()) { return MaybeLocal(); } diff --git a/test/fixtures/json5/objects/numeric-literal-key.json5 b/test/fixtures/json5/objects/numeric-literal-key.json5 new file mode 100644 index 0000000..8829b72 --- /dev/null +++ b/test/fixtures/json5/objects/numeric-literal-key.json5 @@ -0,0 +1,3 @@ +{ + 42: true +}