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
相關文章
相關標籤/搜索