我的$obj
变量具有两个属性,nodes
和rules
。节点没有问题,但是规则有问题:
# Here, I'm converting the specific "rules" property instead of the entire object.
# This is correct and the output should be exactly like this
$obj.rules | ConvertTo-Json
{
"name": "wildcard",
"description": "match all request",
"include": {
"path": [
"*"
]
}
}
但是,将整个对象转换为JSON会导致:
$obj | ConvertTo-Json
{
"nodes": {
#Nodes are displayed correctly here
},
"rules": [
{
"name": "wildcard",
"description": "match all request",
"include": "@{path=System.Object[]}"
}
]
看看最后一行,我不知道为什么会这样。 我正在尝试转换整个对象并将其导出到JSON文件。
我什至尝试将两个对象的属性分别转换并将其合并为一个变量,以便导出JSON文件,但还没有弄清楚。
关于为什么会这样的任何想法?解决方法?
请告知!