Fixes infinite numbers possibly corrupting JSON output.