JSON结构在转换往返过程中不存在

JSON结构在转换往返过程中不存在,json,powershell,Json,Powershell,此命令: ConvertTo-Json (ConvertFrom-Json '{ "abc": [ [1, 2, 3], 4, [5, 6, 7] ] }') 返回: { "abc": [ [ 1, 2, 3 ], 4, [ 5, 6, 7 ] ] } { "abc": { "abc": [ "1 2 3", 4, "5 6 7" ] } } 但是,以下参数在更深层次上具有相同的值: ConvertTo-Json (ConvertFrom-Json '{ "abc": { "abc"

此命令:

ConvertTo-Json (ConvertFrom-Json '{ "abc": [ [1, 2, 3], 4, [5, 6, 7] ] }')
返回:

{ "abc":  [ [ 1, 2, 3 ], 4, [ 5, 6, 7 ] ] }
{ "abc":  { "abc":  [ "1 2 3", 4, "5 6 7" ] } }
但是,以下参数在更深层次上具有相同的值:

ConvertTo-Json (ConvertFrom-Json '{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }')
返回:

{ "abc":  [ [ 1, 2, 3 ], 4, [ 5, 6, 7 ] ] }
{ "abc":  { "abc":  [ "1 2 3", 4, "5 6 7" ] } }
这是虫子吗

理想情况下,我想知道传递给ConvertTo Json的PowerShell值是什么,以便生成第二个示例中的Json,即:

'{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }'
我通常使用ConvertFrom Json来查找这些值。

将-Depth 3传递给ConvertTo Json可以解决这个问题:

ConvertTo-Json -Compress -Depth 3 (ConvertFrom-Json '{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }')
产生:

{"abc":{"abc":[[1,2,3],4,[5,6,7]]}}
将-Depth 3传递给ConvertTo Json解决了这个问题:

ConvertTo-Json -Compress -Depth 3 (ConvertFrom-Json '{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }')
产生:

{"abc":{"abc":[[1,2,3],4,[5,6,7]]}}

有人怀疑Powershell对JSON结构的深度有限制。根据默认深度是2。有人怀疑Powershell对JSON结构的深度有限制。根据默认深度是2。