Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created February 16, 2015 14:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dfinke/2444aef8ebee03db708d to your computer and use it in GitHub Desktop.
Save dfinke/2444aef8ebee03db708d to your computer and use it in GitHub Desktop.
Using PowerShell to Convert From JSON to CSV format
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
@Bassmann
Copy link

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