Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks, none of these suggestions work in my fiddle so I think I might have deeper problems. Commented Jan 23, 2014 at 21:05
  • @SteveAustin The problem in your fiddle is that x isn't valid Json. See my updated answer. Commented Jan 23, 2014 at 22:16
  • Thanks, That works. I was weary to use try / catch after looking in to it more. I ended up simply testing for [ and if not there leave empty. var a = jQuery(this).text(), str = a.substr(0, 1), if (str.indexOf('[') == -1) { jQuery(this).empty(); } This seems to work for my purposes. Commented Jan 24, 2014 at 17:37
  • @SteveAustin That still wouldn't guarantee that the string was valid Json (e.g. [+] would pass). A try/catch is still safer, but yeah, maybe that's sufficient for your particular use case. Commented Jan 24, 2014 at 17:41