ID=62676184
- 读相关:
ConvertFrom-Json
- 写相关:
ConvertTo-Json
# 写入 Json
$Path = "\\VBOXSVR\Public\Docs\config.json"
$data = [pscustomobject]@{
dirtools = "htp1";
dir = "htp2"
}
$data | ConvertTo-Json | Set-Content -Path $Path
##################################
{
"dirtools": "htp1",
"dir": "htp2"
}
# 读取 Json 到 list
$Path = "\\VBOXSVR\Public\Docs\config.json"
function JsonToList($Path)
{
$op = Get-Content -Path $Path -Raw | ConvertFrom-Json
$op | ForEach-Object { "{0} - {1}" -f $_.name, $_.url }
}
############################
dirtools - https://dirtools.com
dir - https://dir.com
网友评论