I have a csv file and when I convert it using convertto-json i am getting the following error
ConvertTo-Json : The converted JSON string is in bad format. At line:1 char:70 + Get-Content -path E:\test.csv | ConvertFrom-Csv -Delimiter ',' | ConvertTo-J ... + ~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (@{name=WebError.Show; data=1}:PSObject) [ConvertTo-Json], InvalidOperationException + FullyQualifiedErrorId : JsonStringInBadFormat,Microsoft.PowerShell.Commands.ConvertToJsonCommand
when i use -compress with convertto-json i am getting the output, but its a compressed json version which is ugly to see, is there a better way to convert this csv to json or is there a way to decompress the json
CSV:
name,data
Play,http://{gho}.domain.com/
BDomain,domain.com
Charts,2
Compress,0
CompressJ,0
WebError.Show,1
Compressed Json Output:
[{"name":"Play","data":"http://{gho}.domain.com/"},{"name":"BDomain","data":"domain.com"},{"name":"Charts","data":"2"},{"name":"Compress","data":"0"},{"name":"CompressJ"
,"data":"0"}]
Get-Contentinto aConvertFrom-Csv? Would it not be easier to useImport-Csv?