json text needs to wrap in parenthesis. why?
if you look at http://www.json.org/js.html you wi开发者_高级运维ll find a line that states:
The text must be wrapped in parens to avoid tripping on an ambiguity in JavaScript's syntax.
var myObject = eval('(' + myJSONtext + ')');
can some body explain what this ambiguity is ???
Many thanks
From here: http://rayfd.wordpress.com/2007/03/28/why-wont-eval-eval-my-json-or-json-object-object-literal/
"Note that an ExpressionStatement cannot start with an opening curly brace because that might make it ambiguous with a Block"
精彩评论