Skip to content

Instantly share code, notes, and snippets.

@dragon788
Forked from dfinke/ConvertFrom-JsonToCsv.ps1
Last active March 8, 2017 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragon788/cc93734aabdc34a8195bcaa9b7e7c366 to your computer and use it in GitHub Desktop.
Save dragon788/cc93734aabdc34a8195bcaa9b7e7c366 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
}
}
# Is there a better way to do this with a foreach key in inputCSV do key:value?
'[{"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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment