"invalid label" Error When Eval JSON
written by Steven on October 25, 2007
If you are getting an "invalid label" error when doing eval() on a json string, here is the solution:
You must do eval('(' + jsonObj + ')') to fix this. I know this seems really stupid, but http://www.json.org/js.html shows just this same example. I wrote a function to handle this:
function jeval(str){return eval('(' + str + ')')}
and then I call jeval() instead of eval();
Business Owners: save hours per week with
LessAccounting. It's like Quickbooks, just not total shit.
Leave a Comment
About Steven
Popular Articles
Subscribe

Steven Bristol has written code for the past 20 years. He like green vegetables and kittens, oh and butterflies too. He loves to throw ninja stars at his enemies.

2 Comments
Thank You,its working.but may i know the reason please.
It’s because the parenthesis are required for javascript to know what to do with it.