Ticket #10336 (closed bug: invalid)
parseJSON validation is inaccurate
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | core | Version: | 1.6.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The current method for validating JSON for parsing is inaccurate and buggy. For example, jQuery.parseJSON("{,}") passes the existing test, and results in a syntax error when trying to eval it, where jquery should handle the error.
This patch introduces an alternative validation method that really ensures that the input is valid JSON before evaluating it:
https://github.com/jquery/jquery/pull/516
JQuery 1.4.1+ affected on all platforms
Change History
comment:1 Changed 20 months ago by rwaldron
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from new to closed
- Component changed from unfiled to core
comment:2 Changed 20 months ago by anonymous
The behavior is inconsistent, though, because the method of validation is bogus.
comment:3 Changed 20 months ago by rwaldron
Sorry, but that "json" string is the only bogus thing here...
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

That error is exactly correct, "{,}" is not valid
http://gyazo.com/88815ad637cc0fccc9ee58751c45d0f9.png http://gyazo.com/fe06c62923b84b8b5a5aa8939fd43fb9.png
jsonlint... http://gyazo.com/a604c8ccff158be76b83288b337d2a0c.png