Added check for valid json

Hi @sixdayz I've added an extra check in case the request doesn't return valid JSON