diff --git a/src/jsonify/parse.ts b/src/jsonify/parse.ts index 91c0fe0e527..0e2ae9b0922 100644 --- a/src/jsonify/parse.ts +++ b/src/jsonify/parse.ts @@ -33,6 +33,10 @@ function unpack( const current = arr[idx]; if (typeof current === "number") { + if (idx !== 0) { + hydrated[idx] = current; + return; + } switch (current) { case UNDEFINED: hydrated[idx] = undefined; diff --git a/src/jsonify/parse_test.ts b/src/jsonify/parse_test.ts index 8e5a1b88df1..42b17f1cbf3 100644 --- a/src/jsonify/parse_test.ts +++ b/src/jsonify/parse_test.ts @@ -97,3 +97,7 @@ Deno.test("parse - circular references", () => { Deno.test("parse - object", () => { expect(parse('[{"foo":1},42]')).toEqual({ foo: 42 }); }); + +Deno.test("parse - object with number negative", () => { + expect(parse('[{"foo":1}, -1]')).toEqual({ foo: -1 }); +});