Direct imaging spectroscopy of substellar companions with JWST