go to bug id or search bugs for
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.
Add a Patch
Add a Pull Request
You propose to add another data-structure on the language level which will have the same semantics as arrays but another syntax or what?
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.
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.
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.
Not long ago a similar solution has been proposed as RFC, but
it was rejected.
Changing package; this isn't a spec bug as such. New features should be proposed as RFCs, generally speaking.
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 (email@example.com) 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 (http://php.net/mailing-lists.php) 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.