Use try and catch when working with JSON.parse() to handle exceptions #1420
Unanswered
espruino-discuss
asked this question in
JavaScript
Replies: 3 comments
-
Posted at 2020-07-30 by Frida You are missing the last " in "three" |
Beta Was this translation helpful? Give feedback.
0 replies
-
Posted at 2020-07-30 by @MaBecker Yes, 😁🤟👍🏻 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Posted at 2020-07-30 by @MaBecker I removed it to force an error |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-07-30 by @MaBecker
Use JSON.parse(data) to validate e.g. received content. Throws a SyntaxError if JSON.parse() can't handle it because it is invalid.
Beta Was this translation helpful? Give feedback.
All reactions