Req #68178 [Com]: JSON Native Support
[email protected] ("cmbecker69 at gmx dot de")
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=68178&edit=1 ID: 68178 Comment by: cmbecker69 at gmx dot de Reported by: php at xkr dot es Summary: JSON Native Support Status: Open Type: Feature/Change Request Package: PHP Language Specification Operating System: N/A PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Not long ago a similar solution has been proposed as RFC[1], but it was rejected. [1] <https://wiki.php.net/rfc/bare_name_array_literal> Previous Comments: ------------------------------------------------------------------------ [2014-10-08 08:19:43] 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 01:51:59] [email protected] 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-07 14:04:37] 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-07 13:52:09] 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 13:48:40] php at xkr dot es Description: ------------ 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: $a=Array(Array("a"=>"b","c"=>CONST,"d"=>null),Array("e"=>1.23),Array("f"=>true)); You could do: $a=[{"a":"b","c":CONST,"d":null},{"e":1.23},{"f":true}]; 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68178&edit=1