Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

fixed error messages of JSON parsing is failed #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ivan-demchenko
Copy link

I stumbled upon a nasty behaviour. I had an issue with one of the 100+ schemas is my RAML and it took me a few hours to debug the code and find out that the reason was a missing comma.

Now, if JSON parsing has failed, it will show the place where the issue is:

Unexpected string in JSON at position 16
{"some": "json" "that-is": "wrong"}
---------------^

@IvanGoncharov
Copy link
Member

@raqystyle Thanks for PR, cool feature 👍
I think it's valueable beyound this library.
So it would be great if you release it as NPM package.

I would merge it either way, just one suggestion it would be better if you just wrap JSON.parse.

@ivan-demchenko
Copy link
Author

ivan-demchenko commented Mar 9, 2018

@IvanGoncharov I had the same idea of a separate npm package and already looking into differences between platforms ;)

As to your suggestion, I hope I got your idea correctly ;)

UPD: the PR's been updated

@IvanGoncharov
Copy link
Member

@raqystyle Looks good for me 👍
@MikeRalphson What do you think?

@MikeRalphson
Copy link

Should we allow the optional reviver parameter to be passed through to maintain compatibility?

@ivan-demchenko
Copy link
Author

@MikeRalphson I agree. I've started on this little lib, the core idea of which is to just provide a better error message.

@ivan-demchenko
Copy link
Author

@IvanGoncharov @MikeRalphson I've updated the PR ;)

@ivan-demchenko
Copy link
Author

@MikeRalphson this is a very good point. Fixed ;)

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

Successfully merging this pull request may close these issues.

None yet

4 participants