Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#13602 closed bug (notabug)

parseJSON() chokes on embedded tab

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:



results in

SyntaxError: Unexpected token

Change History (3)

comment:1 Changed 10 years ago by dmethvin

Resolution: notabug
Status: newclosed

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.

comment:2 Changed 10 years ago by anonymous

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 dmethvin

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.