note 96895 added to function.json-encode
| From: | spam at dvlpt dot com | Date: | Sun, 21 Mar 2010 21:26:17 +0000 |
| Subject: | note 96895 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167280@lists.php.net to get a copy of this message | ||
Regarding [garydavis at gmail dot com],
You should not wrap JSON output in parens or semicolons because that is not properly formatted JSON.
Wrapping JSON in parens is only needed when you are using JavaScript's eval() method to get the
objectified version of a JSON string. Keep in mind, using eval() is terribly slow and insecure for
many reasons (try a web search for "eval is evil").
So, if you absolutely must use eval() to convert your JSON string into a JSON object, you should be
padding the JSON string with parens just before you evaluate it. Anything else is an abuse of the
JSON standard (notable exception being JSONp).
In any case where you are able, use a real JSON parser to safely convert to and from JSON in
JavaScript.
- Jason
----
Server IP: 216.235.13.26
Probable Submitter: 129.97.120.235
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/96895
Del: integrated -- https://master.php.net/note/delete/96895/integrated
Del: useless -- https://master.php.net/note/delete/96895/useless
Del: bad code -- https://master.php.net/note/delete/96895/bad+code
Del: spam -- https://master.php.net/note/delete/96895/spam
Del: non-english -- https://master.php.net/note/delete/96895/non-english
Del: in docs -- https://master.php.net/note/delete/96895/in+docs
Del: other reasons-- https://master.php.net/note/delete/96895
Reject -- https://master.php.net/note/reject/96895
Search -- https://master.php.net/manage/user-notes.php