http://www.json.org/js.html
When encountered on the left hand side, the punctuator '{' defines the
start of a block statement, like if{... or while{... etc. The stuff
inside the block is evaluated as if it were a series of statements, so
the script engine attempts to evaluate:
a: 'abc', b: 'def'
and barfs (understandably).
By enclosing the expression in () it is evaluated as if it were the
right hand side of an expression, in which case {} is treated as an
object initialiser. So what you must pass to eval is:
( { /* property names & values */ } )
as a literal string to force it to treat the {} as an object
initialiser.
Wednesday, May 12, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment