jsonlint icon indicating copy to clipboard operation
jsonlint copied to clipboard

jsonlint.parse(PATH) not working

Open CADBOT opened this issue 6 years ago • 2 comments

I didn't see it explicitly mentioned in the docs, but I could have swore the module interface used to take a valid file path or a json string. Perhaps not though (I would be willing to attempt a PR with the feature if interested).

Here is an example

ex.json

{
    "hi": 2
}

app.js

const jsonlint = require('jsonlint');
jsonlint.parse('./ex.json');

Also the README questions why one would ever use this module instead of JSON.parse? I'd say it's worthwhile because this module gives more user friendly error messages for malformed json files than JSON.parse :)

CADBOT avatar Jun 15 '18 21:06 CADBOT

Actually, the fix was quicker than I thought. Here is a PR

CADBOT avatar Jun 15 '18 21:06 CADBOT

@CADBOT, the parse method expects a JSON string. Not a file path. Read the file to a string and pass the result to the parse method.

prantlf avatar May 18 '19 20:05 prantlf