json-lint.js 448 B

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