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.
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 = '!'
/usr/local/bin/jsonlint
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.
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.
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 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.
had the same issue. Was missing that Vim set by default the filetype of a json file to javascript
:setfiletype json
:SyntasticCheck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With