Allan & Steve are the chubby founders of LessEverything. This is their blog, hear them rant, praise, give advice and talk about Just Stuff, Less Accounting, Lovd by Less, More Honey, Less Memories, Code, Business, Design, Marketing
Chat with Us
October 25th, 2007

"invalid label" Error When Eval JSON

written by Steven Bristol

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();

Sorry, comments are closed for this article.