| 1 |
// Depends on jsonlint.js from https://github.com/zaach/jsonlint |
| 2 |
|
| 3 |
CodeMirror.registerHelper("lint", "json", function(text) { |
| 4 |
var found = []; |
| 5 |
jsonlint.parseError = function(str, hash) { |
| 6 |
var loc = hash.loc; |
| 7 |
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), |
| 8 |
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column), |
| 9 |
message: str}); |
| 10 |
}; |
| 11 |
try { jsonlint.parse(text); } |
| 12 |
catch(e) {} |
| 13 |
return found; |
| 14 |
}); |
| 15 |
CodeMirror.jsonValidator = CodeMirror.lint.json; // deprecated |
| 16 |
|