issue #22155: Handle toJSON exception case so tests pass.