Created
February 16, 2015 14:28
-
-
Save dfinke/2444aef8ebee03db708d to your computer and use it in GitHub Desktop.
Using PowerShell to Convert From JSON to CSV format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertFrom-JsonToCsv { | |
param( | |
[Parameter(ValueFromPipeline)] | |
$json | |
) | |
Process { | |
($json | ConvertFrom-Json) | ConvertTo-Csv -NoTypeInformation | |
} | |
} | |
'[{"Column 1": "1-1","Column 2": "1-2","Column 3": "1-3","Column 4": "1-4"},{"Column 1": "2-1","Column 2": "2-2","Column 3": "2-3","Column 4": "2-4"},{"Column 1": "3-1","Column 2": "3-2","Column 3": "3-3","Column 4": "3-4"},{"Column 1": 4,"Column 2": 5,"Column 3": 6,"Column 4": 7}]' | | |
ConvertFrom-JsonToCsv |
This is not a script but a Powershell function. In a script you would source that file and the ncall the function as in the example on line 12
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you help me how to run this script in Powershell ISE?
I've come to the following steps but keep getting errors
How should I call the file as an argument?