|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68178 JSON Native Support
Submitted: 2014-10-07 13:48 UTC Modified: 2017-08-05 04:55 UTC
Avg. Score:2.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at xkr dot es Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
34 + 34 = ?
Subscribe to this entry?

 [2014-10-07 13:48 UTC] php at xkr dot es
It will be fine if native support of JSON blocks will be added in the future to the language specification. The functions json_encode and json_decode provides the functionality, but it will be better if they were native supported.

For example, instead of doing:

You could do:

As you can see, JSON it's very compact and it's easy to read, also it distinguishes about arrays and hashes, so its better to understand.

I hope this comment will be considered for next versions.

Best regards.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-07 13:52 UTC] inefedor at gmail dot com
You propose to add another data-structure on the language level which will have the same semantics as arrays but another syntax or what?
 [2014-10-07 14:04 UTC] php at xkr dot es
Shortly, yes. This is not to be considered as an "echo" or "print" alias discussion.

In a broader term, JSON is the data structure most used by programmers in the web development, so I propose a convergence to this widely used data structure.

There are a lot of this to do in PHP, and I conseder this is not the first one, but it will be fine if PHP programmers consider this for the future.

Thanks for your comment.
 [2014-10-08 01:51 UTC]
You could also use short array syntax:

$a = [['a' => 'b', 'c' => 'CONST', 'd' => null], ['e' => 1.23], ['f' => true]];

Two less characters and I had enough room to space everything out.
 [2014-10-08 08:19 UTC] php at xkr dot es
Thanks datibbaw, first heard about that, I've just seen it was introduced in PHP 5.4, it's a great approximation to the JSON structure, although is not compatible for the arrow, but at least it's cleaner. I hope anyway the consideration of a full support will be great. If you think it will not be an improvement, close the suggestion. Thanks again.
 [2014-10-08 15:00 UTC] cmbecker69 at gmx dot de
Not long ago a similar solution has been proposed as RFC[1], but
it was rejected.

[1] <>
 [2014-10-23 18:10 UTC]
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2014-10-23 18:10 UTC]
Changing package; this isn't a spec bug as such. New features should be proposed as RFCs, generally speaking.
 [2017-08-05 04:55 UTC]
-Status: Open +Status: Suspended
 [2017-08-05 04:55 UTC]
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list ( as an RFC. Please read the guide about creating RFCs here:
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list ( and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jun 03 01:01:25 2020 UTC