diff --git a/src/impl/parser.ts b/src/impl/parser.ts index 2e7d815..36de808 100644 --- a/src/impl/parser.ts +++ b/src/impl/parser.ts @@ -197,8 +197,8 @@ export function parse(text: string, errors: ParseError[] = [], options: ParseOpt currentParent = previousParents.pop(); }, onLiteralValue: onValue, - onError: (error: ParseErrorCode, offset: number, length: number) => { - errors.push({ error, offset, length }); + onError: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => { + errors.push({ error, offset, length, startLine, startCharacter }); } }; visit(text, visitor, options); @@ -260,8 +260,8 @@ export function parseTree(text: string, errors: ParseError[] = [], options: Pars } } }, - onError: (error: ParseErrorCode, offset: number, length: number) => { - errors.push({ error, offset, length }); + onError: (error: ParseErrorCode, offset: number, length: number, startLine: number, startCharacter: number) => { + errors.push({ error, offset, length, startLine, startCharacter }); } }; visit(text, visitor, options); diff --git a/src/main.ts b/src/main.ts index f26bf20..5bd3566 100644 --- a/src/main.ts +++ b/src/main.ts @@ -144,6 +144,8 @@ export interface ParseError { error: ParseErrorCode; offset: number; length: number; + startLine: number; + startCharacter: number; } export const enum ParseErrorCode { diff --git a/src/test/json.test.ts b/src/test/json.test.ts index 2f2a30e..9fba85c 100644 --- a/src/test/json.test.ts +++ b/src/test/json.test.ts @@ -431,8 +431,8 @@ suite('JSON', () => { } ] }, [ - { error: ParseErrorCode.PropertyNameExpected, offset: 26, length: 1 }, - { error: ParseErrorCode.ValueExpected, offset: 26, length: 1 } + { error: ParseErrorCode.PropertyNameExpected, offset: 26, length: 1, startLine: 0, startCharacter: 26 }, + { error: ParseErrorCode.ValueExpected, offset: 26, length: 1, startLine: 0, startCharacter: 26 } ]); }); @@ -678,7 +678,7 @@ suite('JSON', () => { ], colonOffset: 37 } ] - }, [{ error: ParseErrorCode.ColonExpected, offset: 49, length: 1 }]); + }, [{ error: ParseErrorCode.ColonExpected, offset: 49, length: 1, startLine: 0, startCharacter: 49 }]); }); test('tree: find location', () => {