note 110522 added to function.json-decode
| From: | benkuhl at gmail dot com | Date: | Thu, 01 Nov 2012 15:34:16 +0000 |
| Subject: | note 110522 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191626@lists.php.net to get a copy of this message | ||
Do not rely on json_decode to validate your JSON. The following JSON string was decoded incorrectly
when I would've expected it to throw an error...
{
"request": {
"filterBy": "MCC" //missing a comma
"startDate": "Sun, 02 Sep 2012 12:51:44 -0400",
"endDate": "Tue, 02 Oct 2012 00:00:00 -0400"
}
}
Item was decoded as...
array(
"request" => array(
"filterBy" => "Sun, 02 Sep 2012 12:51:44 -0400",
"endDate" => "Tue, 02 Oct 2012 00:00:00 -0400"
)
)
Notice there's no start date
----
Server IP: 69.147.83.199
Probable Submitter: 74.143.144.100
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/110522
Del: integrated -- https://master.php.net/note/delete/110522/integrated
Del: useless -- https://master.php.net/note/delete/110522/useless
Del: bad code -- https://master.php.net/note/delete/110522/bad+code
Del: spam -- https://master.php.net/note/delete/110522/spam
Del: non-english -- https://master.php.net/note/delete/110522/non-english
Del: in docs -- https://master.php.net/note/delete/110522/in+docs
Del: other reasons-- https://master.php.net/note/delete/110522
Reject -- https://master.php.net/note/reject/110522
Search -- https://master.php.net/manage/user-notes.php