From 18101841863b571dbb2cb901318c73dbebca6acb Mon Sep 17 00:00:00 2001 From: Andrey Gubanov Date: Wed, 16 Sep 2020 15:53:58 +0300 Subject: [PATCH] add updated web version --- web/jsonlint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/jsonlint.js b/web/jsonlint.js index b5ee237..6d743bf 100644 --- a/web/jsonlint.js +++ b/web/jsonlint.js @@ -782,8 +782,12 @@ jsonlint.parse = function(input) { dougJSONParse(input); } catch(e) { if(/Duplicate key|Bad string|Unexpected/.test(e.message)) { - var lineNumber = input.substring(0, e.at).split('\n').length; - throw SyntaxError(e.message + ' on line ' + lineNumber); + var linesUntilError = input.substring(0, e.at).split('\n'); + var line = linesUntilError.length; + var col = linesUntilError[line - 1].length - 1; + + this.parseError(e.message, {line: line, col: col, message: e.message.replace(/./, function(l) { return l.toLowerCase(); })}); + throw SyntaxError(e.message + ' on line ' + line); } }