我有以下PowerShell代码:
IForm(42); //or
IForm($ID);
我得到的输出是这样:
$rawJson = '{
"A": [
{
"Attr1": "Value1",
"Attr2": 0
}
],
"B": [
{
"SimpleList": [
"Entry1",
"Entry2"
],
"Id": "myId"
}
]
}';
$jsonConverted = $rawJson | ConvertFrom-Json;
$jsonConverted.A[0].Attr2 = 1;
Write-Host ($jsonConverted | ConvertTo-Json);
我期望的输出是这样:
{
"A": [
{
"Attr1": "Value1",
"Attr2": 1
}
],
"B": [
{
"SimpleList": "Entry1 Entry2",
"Id": "myId"
}
]
}
“ SimpleList”被截断为单个字符串而不是保留单个项目,这是我做错了吗?