Fix bug when JSON is not properly formatted