note 119339 added to function.json-encode
| From: | chris at fuelforthefire dot ca | Date: | Mon, 16 May 2016 19:18:58 +0000 |
| Subject: | note 119339 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205493@lists.php.net to get a copy of this message | ||
echo json_encode('0' => 'Zero', '2' => 'Two');
> {'0' => 'Zero', '2' => 'Two'}
echo json_encode('1' => 'One', '2' => 'Two');
> {'1' => 'One', '2' => 'Two'}
echo json_encode('0' => 'Zero', '1' => 'One',
'2' => 'Two');
> ['Zero', 'One', 'Two']
Whoever decided this default behaviour made sense really must hate programmers. The logic should
either work one or not, you can't pick and choose when something should happen, otherwise how
can you make generic code? How am I supposed to tell someone using my communication protocol,
"Hey, don't use anything that might look like an array cause PHP will break it?"
This needs to be fixed.
----
Server IP: 72.52.91.14
Probable Submitter: 173.176.126.144
----
Manual Page -- http://php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/119339
Del: integrated -- https://master.php.net/note/delete/119339/integrated
Del: useless -- https://master.php.net/note/delete/119339/useless
Del: bad code -- https://master.php.net/note/delete/119339/bad+code
Del: spam -- https://master.php.net/note/delete/119339/spam
Del: non-english -- https://master.php.net/note/delete/119339/non-english
Del: in docs -- https://master.php.net/note/delete/119339/in+docs
Del: other reasons-- https://master.php.net/note/delete/119339
Reject -- https://master.php.net/note/reject/119339
Search -- https://master.php.net/manage/user-notes.php