def encode_utf8(data):
    if isinstance(data, dict):
        for key in data:
            data[key] = encode_utf8(data[key])
        return data
    elif isinstance(data, list):
        for i in range(len(data)):
            data[i] = encode_utf8(data[i])
        return data
    elif isinstance(data, type(u'')):
        return data.encode('utf8')
    else:
        return data
def encode_utf8(data):
    if isinstance(data, dict):
        for key in data:
            data[key] = encode_utf8(data[key])
        return data
    elif isinstance(data, list):
        for i in range(len(data)):
            data[i] = encode_utf8(data[i])
        return data
    elif isinstance(data, type(u)):
        return data.encode('utf8')
    else:
        return data