diff --git a/src/impl/parser.ts b/src/impl/parser.ts index 12edd80..5ba1c4a 100644 --- a/src/impl/parser.ts +++ b/src/impl/parser.ts @@ -167,7 +167,7 @@ export function parse(text: string, errors: ParseError[] = [], options: ParseOpt function onValue(value: any) { if (Array.isArray(currentParent)) { (currentParent).push(value); - } else if (currentProperty) { + } else if (currentProperty !== null) { currentParent[currentProperty] = value; } } diff --git a/src/test/json.test.ts b/src/test/json.test.ts index a5878f2..846afa5 100644 --- a/src/test/json.test.ts +++ b/src/test/json.test.ts @@ -262,6 +262,7 @@ suite('JSON', () => { assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }); assertValidParse('{ "hello": { "again": { "inside": 5 }, "world": 1 }}', { hello: { again: { inside: 5 }, world: 1 } }); assertValidParse('{ "foo": /*hello*/true }', { foo: true }); + assertValidParse('{ "": true }', { '': true }); }); test('parse: arrays', () => {