[英]JSON structure not surviving conversion round trip
This command: 该命令:
ConvertTo-Json (ConvertFrom-Json '{ "abc": [ [1, 2, 3], 4, [5, 6, 7] ] }')
returns: 收益:
{ "abc": [ [ 1, 2, 3 ], 4, [ 5, 6, 7 ] ] }
However, the following (the same value at a deeper level): 但是,以下内容(在更深层次上为相同的值):
ConvertTo-Json (ConvertFrom-Json '{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }')
returns: 收益:
{ "abc": { "abc": [ "1 2 3", 4, "5 6 7" ] } }
Is this a bug? 这是错误吗?
Ideally, I'd like to find out what PowerShell value to pass to ConvertTo-Json
in order to produce the JSON in the 2nd example, ie: 理想情况下,我想找出要传递给
ConvertTo-Json
PowerShell值,以便在第二个示例中生成JSON,即:
'{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }'
I usually use ConvertFrom-Json
to find out such values. 我通常使用
ConvertFrom-Json
找出此类值。
Passing -Depth 3
to ConvertTo-Json
solves the problem: 将
-Depth 3
传递给ConvertTo-Json
可以解决此问题:
ConvertTo-Json -Compress -Depth 3 (ConvertFrom-Json '{ "abc": { "abc": [ [ 1, 2, 3 ], 4, [5, 6, 7] ] } }')
produces: 生产:
{"abc":{"abc":[[1,2,3],4,[5,6,7]]}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.