PDA

View Full Version : Json check



pomata
3 Dec 2006, 2:43 PM
Hi, sorry for stupid question,

when I use:

var data = YAHOO.ext.util.JSON.decode(o.responseText);

how do I check o.responseText is a valid JSON data?

Thanks in advance.

Regards

tryanDLS
3 Dec 2006, 2:48 PM
decode used to throw a SyntaxError - it's commented out for some reason. In the interim, you could just wrap that call in a try/catch

pomata
3 Dec 2006, 3:23 PM
Many tx,

That did the trick....

Pomata

jack.slocum
3 Dec 2006, 5:34 PM
The regex check had to go. It crashed Safari. Try/catch is the way to go.