util.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:eclipse2017 作者: google 项目源码 文件源码
def _escape_json(json):
    """Escapes all string fields of JSON data.

       Operates recursively."""
    t = type(json)
    if t == types.StringType or t == types.UnicodeType:
        return cgi.escape(json)
    elif t == types.IntType:
        return json
    elif t == types.FloatType:
        return json
    elif t == types.DictType:
        result = {}
        for f in json.keys():
            result[f] = _escape_json(json[f])
        return result
    elif t == types.ListType:
        result = []
        for f in json:
            result.append(_escape_json(f))
        return result
    else:
        raise RuntimeError, "Unsupported type: %s" % str(t)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号