Skip to content

json.tolerantParse(...) API should be tolerant of trailing commas with trailing comments #1076

@DustinCampbell

Description

@DustinCampbell

The following unit test should pass:

test("ignore trailing comma in object member list with comment at end of line", () => {
    const text =
        `{
"obj": {
    "a" : 1, // Comment
}
}`;

    const expected =
        `{
"obj": {
    "a": 1
}
}`;

    let json = tolerantParse(text);
    let result = JSON.stringify(json, null, 4);

    result.should.equal(expected);
});

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions