Skip to content

Instantly share code, notes, and snippets.

@jeffyuhaoliu
Forked from janbaer/gist:5045798
Last active December 19, 2015 19:18
Show Gist options
  • Save jeffyuhaoliu/6004713 to your computer and use it in GitHub Desktop.
Save jeffyuhaoliu/6004713 to your computer and use it in GitHub Desktop.
- Fixed a bug where string value of double quote causes an error "The converted JSON string is in bad format."
param
(
[string] $inputFile,
[string] $outputFile
)
if (($inputFile -eq $null) -or ($outputFile -eq $null)) {
"usage: convert_csv_to_json.ps1 [inputFile] [outputFile]"
return;
}
elseif ((Test-Path $inputFile) -eq $false) {
"The file $inputFile doesnt exists!"
return;
}
Get-Content -path $inputFile | ConvertFrom-Csv -Delimiter ';' | ConvertTo-Json -Compress | Out-File $outputFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment