Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Syntastic catch JSON errors?

Tags:

vim

syntastic

I just added jsonlint for Syntastic, and it's not catching any syntax errors. flake8 is working fine for Python, and has been for a while, but no jsonlint. Below you'll see the relevant portion of my .vimrc, where I believe to have everything I need to get this next checker working.

.vimrc

let g:syntastic_python_checkers=['flake8']
let g:syntastic_python_flake8_args = '--ignore="E501"' " ignore long lines
let g:syntastic_json_checkers=['jsonlint']

" Better :sign interface symbols
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '!'

which jsonlint

/usr/local/bin/jsonlint
like image 284
Brian Dant Avatar asked May 18 '13 00:05

Brian Dant


People also ask

Does JSON have syntax errors?

Just like every programming language, a JSON file has a fixed syntax. Small syntax errors throws errors. For example, in the following code, i forgot to remove a trailing comma How to Catch The Error Before Hand? The problem with debugging JSON errors are that you get to know about one error at a time.

How does syntastic handle errorformat?

Well, syntastic runs some checkers against your files using the makeprg mechanism, then tries to parse the results with errorformat, and shows them nicely in a window. Some of the checkers rely on helper scripts to re-format the results, but they don't try to do anything clever beyond that.

Why is my JSON string not valid?

If you specify the WITHOUT_ARRAY_WRAPPER option in the inner FOR JSON, the resulting JSON text is not necessarily valid JSON. Therefore the outer FOR JSON assumes that this is plain text and escapes the string.

How to handle error in isjsonstring () method?

How to handle it. There are several way to handle error. Try catch block is one of them which is as follow: function IsJsonString (str) { try { JSON.parse (str); } catch (e) { return false; } return true; } Another way is to test using regex expression and then using try catch block to reducer the execution time.


1 Answers

had the same issue. Was missing that Vim set by default the filetype of a json file to javascript

:setfiletype json
:SyntasticCheck
like image 72
jassinm Avatar answered Sep 20 '22 03:09

jassinm