【发布时间】:2021-01-21 11:53:38
【问题描述】:
我有一个 JSON,我想检查它是否为数组,如果不是,我想更新 JSON 并将其更改为数组
{
"Customer": [{
"id": "123"
}],
"address": {
"type": "home",
"name": "what",
"description": "",
"adi:water": {
"type": "comp",
"location": "grass"
},
"att": [
{
"name": "cat",
"type": "int"
},
{
"name": "ds",
"type": "string"
}
]
}
}
#For example address is not an array, I want to change so address is an array of one single object
到目前为止的代码
$File = ((Get-Content -Encoding UTF8 -path Test.json -Raw)
$File = $File| ConvertFrom-Json
$File.address = $File.address | Select-Object * -ExcludeProperty streets #This line changes it to an object instead of an array
我希望地址是一个数组。我可以在 powershell 中这样做吗?
【问题讨论】:
标签: json powershell powershell-core