-
Notifications
You must be signed in to change notification settings - Fork 77
Show error if JSON is invalid #156
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
Comments
The error is shown as I see now, but it's subtle and hard to decipher. |
I can send a PR that would use https://github.com/json5/json5 instead of vanilla JSON.parse for parsing the |
I agree that this would be better. One thing that concerned me a bit about using JSON5 is that it would be somewhat jarring when the component updates the data, because it would have to stringify the current state in a way that is unlikely to match the user's formatting. So I whipped up a little module that makes it possible to update the string in place: https://github.com/Rich-Harris/golden-fleece The idea is that you take a JSON5 string, throw a new object at it, and it will 'patch' the string to add the new values non-destructively. (It isn't at all battle-tested yet!) A PR would be awesome if you have time! Thank you 😀 |
Heh, nice module. Will try to find time early this (coming) week. |
this is now implemented |
Via sveltejs/svelte#938 — if a gist contains invalid JSON, the REPL doesn't appear to mind: https://svelte.technology/repl?version=1.42.0&gist=2afe785004bcdc4c1bcca6f03f2ed7f9
It should show an error instead.
The text was updated successfully, but these errors were encountered: