More fixes to parsing of invalid JSON (related to issue 6669)