Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonlint.parse(PATH) not working #110

Open
CADBOT opened this issue Jun 15, 2018 · 2 comments
Open

jsonlint.parse(PATH) not working #110

CADBOT opened this issue Jun 15, 2018 · 2 comments

Comments

@CADBOT
Copy link

CADBOT commented Jun 15, 2018

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
Copy link
Author

CADBOT commented Jun 15, 2018

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

@prantlf
Copy link

prantlf commented May 18, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants