safer json data parsing

This commit skips parsing of JSON data entirely when it is left undefined, as might happen with a connection error. Previously this resulted in an "Unexpected token u" error in the browser.