more defensive json parsing