note 96955 deleted from function.json-encode by danbrown
| From: | danbrown@php.net | Date: | Wed, 24 Mar 2010 22:01:50 +0000 |
| Subject: | note 96955 deleted from function.json-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167364@lists.php.net to get a copy of this message | ||
Note Submitter: pgraham at NOADDR dot sitebrand dot NOADDR dot com
----
RE: spam at dvlpt dot com
While it is true that eval() is often poorly, JSON is one case where it is exactly what you need.
eval() is NOT slow when it is used to turn a JSON string into a useable object. If you don't
believe you can look at the jQuery source. The line they use is: data =
window['eval']('(' + data + ')'); which is effectively an eval().
The only reason to not use eval() directly is to perform validation on a JSON string. If the string
comes from a server that you trust (ie. one you control), eval() is the method to use.