#13602 closed bug (notabug)
parseJSON() chokes on embedded tab
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
$.parseJSON('[{"name":"a\tb"}]');
results in
SyntaxError: Unexpected token
Change History (3)
comment:1 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
pphp json_encode() will generate it.
And jsonlint.com will validate it.
Not that those are necessarily authoritative, but something to consider.
(P.S. I tried to paste some php+javascript code, but cannot. Is there a jsfiddle-like site for php?)
comment:3 Changed 10 years ago by
At some point your code is letting something change "\t" to a tab character. Please ask for help on a forum. This isn't a jQuery bug.
Note: See
TracTickets for help on using
tickets.
The strings in JSON can't have control characters, as laid out pretty clearly in the diagrams at http://json.org. A tab is a control character. A "\t" in a JavaScript literal string is converted to a tab. If some tool had created that JSON it did not encode it correctly.