note 86358 added to function.json-encode
| From: | stboisvert at nowantspam dot gmail dot com | Date: | Tue, 14 Oct 2008 19:27:48 +0000 |
| Subject: | note 86358 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145361@lists.php.net to get a copy of this message | ||
When Using Libraries such as Prototype you may find that once in a while when you return what you
believe to be a empty array it will have a different behavior (vis a vis enumerables) than when you
give it an associative array. To "fix" this, on your JS you may want to look for extended
object properties to verify if it is an empty array or an ocject.
example:
if (transport.responseJSON['User'].length == undefined){
var user = $H(transport.responseJSON['User']);
}else{
var user = transport.responseJSON['User'];
}
Thanks goes out to :
jani@php.net
This is totally expected behaviour. Please read this:
http://www.json.org/
Note: array and assoc-array are different things. Latter being "object"
in json.
http://bugs.php.net/bug.php?id=45162
----
Server IP: 66.207.199.35
Probable Submitter: 192.197.82.203
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/86358
Del: integrated -- https://master.php.net/note/delete/86358/integrated
Del: useless -- https://master.php.net/note/delete/86358/useless
Del: bad code -- https://master.php.net/note/delete/86358/bad+code
Del: spam -- https://master.php.net/note/delete/86358/spam
Del: non-english -- https://master.php.net/note/delete/86358/non-english
Del: in docs -- https://master.php.net/note/delete/86358/in+docs
Del: other reasons-- https://master.php.net/note/delete/86358
Reject -- https://master.php.net/note/reject/86358
Search -- https://master.php.net/manage/user-notes.php