我正在尝试将数据转换为JSON作为REST API的输入。我面临的挑战是数据应包含多个深度(缺少更好的语言)。我现在使用的代码是:
(@{name = "Contoso"; all_assets = "false"; all_users="false"; rules= @{type="fqdn"; operator="match"; terms=@("contoso") } }| ConvertTo-Json)
现在的输出是:
{
"all_users": "false","name": "Contoso","all_assets": "false","rules": {
"operator": "match","terms": [
"contoso"
],"type": "fqdn"
}
}
REST-Api抱怨数据包含无效字符。查看输出,“规则:”部分包含{}而不是[]。我一直在尝试各种技巧,但似乎无法弄清楚。
有人知道我在做什么错吗?