The following bit of code generates an error
W:\surge\ogre> @{SolutionDir='W:\Surge\ogre\'} | ConvertTo-Json
ConvertTo-Json : The converted JSON string is in bad format.
At line:1 char:35
+ @{SolutionDir='W:\Surge\ogre\'} | ConvertTo-Json
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Collections.Hashtable:PSObject) [ConvertTo-Json], InvalidOperationException
+ FullyQualifiedErrorId : JsonStringInBadFormat,Microsoft.PowerShell.Commands.ConvertToJsonCommand
Why? How could I fix this? This is in a prebuild event so I'm trying to keep it single-line and as compact as possible.
Using the -Compress
switch should solve your problem. I believe this is a bug in PowerShell. Others have had similar problem with ex. values containing double quotes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With