lua转换etcd应答

local function decodeNodes(nodes)
    local table = {}
    for _, value in ipairs(nodes) do
        if value.nodes then
            table[value.key] = decodeNodes(value.nodes)
        elseif value.value then
            table[value.key] = value.value
        end
    end
    return table
end

local function decodeEtcdJson(rootValue, node)
    if node.nodes then
        rootValue[node.key] = decodeNodes(node.nodes)
    elseif node.value then
        rootValue[node.key] = node.value
    end
end

local function transferString2Boolean(s)
    if not s then
        return false
    elseif s == "true" then
        return true
    elseif s == "false" then
        return false
    end
    return true
end
posted @ 2017-07-17 15:57  我的娃会叫爸爸啦  阅读(432)  评论(0编辑  收藏  举报