【发布时间】:2023-04-09 01:13:01
【问题描述】:
在converting 与JSON 之间的上下文中:
也许下面的integer 只是标记数组索引?然而,发送 1,1,1 是完全可能的,所以它不是索引。那么“1”可能表示“深度”?
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> ConvertTo-Json @(1)
[
1
]
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> ConvertTo-Json @(1,a)
ParserError:
Line |
1 | ConvertTo-Json @(1,a)
| ~
| Missing expression after ','.
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> ConvertTo-Json @(1,2)
[
1,
2
]
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> ConvertTo-Json @(a)
a: The term 'a' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
[]
PS /home/nicholas/powershell>
为什么整数可以:
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> ConvertTo-Json @(1,3,9)
[
1,
3,
9
]
PS /home/nicholas/powershell>
但甚至没有一个char?
String 数据似乎都不可接受。
【问题讨论】:
-
JSON 没有
char类型的概念,只有字符串:ConvertTo-Json @(1,'a') -
谢谢,这回答了我的问题(例如)
标签: arrays json powershell type-conversion read-eval-print-loop