| 用途 | JSON 序列化/反序列化 |
|---|---|
| 语法 | <对象> | ConvertTo-Json -Depth 5;Get-Content x.json -Raw | ConvertFrom-Json |
| 要点 | Depth 默认 2,嵌套结构按需增大 |
常用示例
常用示例
Get-Process -Id 4 | Select-Object Name, Id | ConvertTo-Json
$cfg = Get-Content D:\cfg.json -Raw | ConvertFrom-Json
$cfg.Port读取 JSON 文件建议 -Raw 整体解析,避免按行拆分破坏结构。