【发布时间】:2021-12-24 04:52:25
【问题描述】:
尝试了几个命令,例如Get-Content jsonfile.json | Out-String | ConvertFrom-Json,但没有任何效果。
如何将名称、版本、id、作者、描述、部署日期转换为列和新行。
Json 文件示例:
[
{
"name": "ABC",
"version": "1.0.4",
"id": "f5e2b3ed-ac07",
"customer": "Abby",
"description": "An example- \n\nDate:\nFrom:\nTo:\nSubject:\nBody:\nAttachments\n\n\n",
"deploymentDate": 11102021140122,
"deployedBy": "Kathy Hick",
"signDetails": {
"signStatus": "notSigned",
"signedBy": null,
},
{
"name": "This_is_example",
"version": "1.0.4",
"id": "992e-da106ee7fcff",
"publisher": "Customer",
"description": "",
"deploymentDate": 1634762732781,
"deployedBy": "joehannible01",
"signDetails": {
"signStatus": "notSigned",
"signedBy": null,
}
]
【问题讨论】:
-
您好,欢迎来到 SO。在我们继续之前,您应该立即使用Tour 并至少阅读How to Ask 和minimal reproducible example 的帮助主题,以设定您对SO 的期望。无论如何 - 当您发布代码或示例数据时,您应该将它们格式化为代码。提前致谢。
-
您的 JSON 数据无效。如果您使用有效的 JSON,它只会将 JSON 字符串传输到
ConvertFrom-Json并将其传输到Export-Csv或ConvertTo-Csv
标签: arrays powershell csv json.net