def _to_json(self, strip, to_serialize=None):
curr_type = self.__class__<EOL>if to_serialize is None:<EOL><INDENT>to_serialize = copy.copy(self.__dict__)<EOL><DEDENT>else:<EOL><INDENT>to_serialize = copy.copy(to_serialize)<EOL><DEDENT>for member in strip:<EOL><INDENT>if member in to_serialize:<EOL><INDENT>del to_serialize[member]<EOL><DEDENT><DEDENT>to_serialize['<STR_LIT>'] = _parse_expiry(<EOL>to_serialize.get('<STR_LIT>'))<EOL>to_serialize['<STR_LIT>'] = curr_type.__name__<EOL>to_serialize['<STR_LIT>'] = curr_type.__module__<EOL>for key, val in to_serialize.items():<EOL><INDENT>if isinstance(val, bytes):<EOL><INDENT>to_serialize[key] = val.decode('<STR_LIT:utf-8>')<EOL><DEDENT>if isinstance(val, set):<EOL><INDENT>to_serialize[key] = list(val)<EOL><DEDENT><DEDENT>return json.dumps(to_serialize)<EOL>
Utility function that creates JSON repr. of a Credentials object.

        Args:
            strip: array, An array of names of members to exclude from the
                   JSON.
            to_serialize: dict, (Optional) The properties for this object
                          that will be serialized. This allows callers to
                          modify before serializing.

        Returns:
            string, a JSON representation of this instance, suitable to pass to
            from_json().