|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57209 Tabs in Javascript strings break json_decode()
Submitted: 2006-08-30 16:31 UTC Modified: 2006-08-31 11:25 UTC
From: Assigned:
Status: Not a bug Package: json (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2006-08-30 16:31 UTC]
print_r(json_decode('{ "abc": 12, "foo": "bar   bar" }'));

With a TAB between bar bar there doesn't work.  It works in the 1.1.x version before the rewrite, but breaks now in 1.2.1.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 00:23 UTC]
I don't think this is valid JSON as per the JSON spec.

(Using JSON_checker from:

[omar@xxx jc]$ cat tab.json 
{ "abc": 12, "foo": "bar        bar" }
[omar@xxx jc]$ ./JSON_checker tab.json 
tab.json syntax error at character 24

Since json_decode is based on JSON_checker, it'll just return NULL here due to the "invalid" JSON input.

I'm not sure whether this is right or wrong -- I'd have to ask Douglas.

Shouldn't the tab be a \t if encoded using json_encode?
 [2006-08-31 11:25 UTC]
Ok, the word from Douglas is that it is indeed illegal to have raw tabs there.  No bug here.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 19:01:27 2023 UTC