Convert JSON to CSV using PowerShell

后端 未结 3 2044
借酒劲吻你
借酒劲吻你 2020-12-16 21:51

I have a sample JSON-formatted here which converts fine if I use something like: https://konklone.io/json/

I\'ve tried the following code in PowerShell:



        
3条回答
  •  有刺的猬
    2020-12-16 22:30

    You have to select the results property inside your CSV using the Select-Object cmdlet together with the -expand parameter:

    Get-Content -Path $pathToJsonFile  | 
        ConvertFrom-Json | 
        Select-Object -expand results | 
        ConvertTo-Csv -NoTypeInformation |
        Set-Content $pathToOutputFile
    

提交回复
热议问题