Skip to content

Commit c847392

Browse files
authored
Merge pull request #24 from stoplightio/master
parse function should include properties with empty string as their keys
2 parents 6427999 + 641942f commit c847392

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/impl/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function parse(text: string, errors: ParseError[] = [], options: ParseOpt
167167
function onValue(value: any) {
168168
if (Array.isArray(currentParent)) {
169169
(<any[]>currentParent).push(value);
170-
} else if (currentProperty) {
170+
} else if (currentProperty !== null) {
171171
currentParent[currentProperty] = value;
172172
}
173173
}

src/test/json.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ suite('JSON', () => {
262262
assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} });
263263
assertValidParse('{ "hello": { "again": { "inside": 5 }, "world": 1 }}', { hello: { again: { inside: 5 }, world: 1 } });
264264
assertValidParse('{ "foo": /*hello*/true }', { foo: true });
265+
assertValidParse('{ "": true }', { '': true });
265266
});
266267

267268
test('parse: arrays', () => {

0 commit comments

Comments
 (0)