This fixes this issue #31301 .
This problem only applies to the BasicJsonParser since the other parser return exceptions that give details of the malformed JSON.
I choose the exception that the JacksonJsonParser returns on malformed JSON, JsonParseException. the GsonJsonParser returns a MalformedJsonException.
Not sure exactly if the project has a preferable way of handling null cases like this.
Didn't add the proposed test from the issue because I suspect there will be another PR to write tests for malformed JSON that assert the exception on malformed JSON parsing.
Comment From: wilkinsona
Thanks for the pull request, @Egraveline, but there's a bit more to this one. Please see my comment on the issue for details.