Exit if json parsing fails

If the webpage is under construction, API might return html 404 page
instead of json. So make sure what we get is actually json and not
something else.