"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();
Learn how LessEverything built their consultancy to over $1,000,000 annual revenue at LessMoney Conference, June 7th in Tampa Florida. Each attendee will get early access to our upcoming ebook as well.
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.
