Run a business? Check out LessAccounting, our bookkeeping system that'll save you hours per week.

Announcing:

We built the entrepreneur's bookkeeping system, it's called LessAccounting. You'll probably love it.

"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.

2 Comments

goutham
goutham said on June 12, 2012

Thank You,its working.but may i know the reason please.

Steven Bristol
Steven Bristol said on June 12, 2012

It’s because the parenthesis are required for javascript to know what to do with it.

Leave a Comment

About Steven
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.

You Should...

Follow Steven on Twitter
Friend Steven on Facebook
Subscribe
LessEverything Copyright 2011 LessEverything.com
We don't like footers, they're kinda boring