'Utility function that creates JSON repr. of a Credentials object.
Args:
strip: array, An array of names of members to not include in the JSON.
Returns:
string, a JSON representation of this instance, suitable to pass to
from_json().'

def _to_json(self, strip):

    t = type(self)
    d = copy.copy(self.__dict__)
    for member in strip:
        if (member in d):
            del d[member]
    if (d.get('token_expiry') and isinstance(d['token_expiry'], datetime.datetime)):
        d['token_expiry'] = d['token_expiry'].strftime(EXPIRY_FORMAT)
    d['_class'] = t.__name__
    d['_module'] = t.__module__
    for (key, val) in d.items():
        if isinstance(val, bytes):
            d[key] = val.decode('utf-8')
    return json.dumps(d)
