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.
为什么?我怎么能解决这个问题?这是在预建事件中,所以我试图保持它的单行和尽可能紧凑。
1 个解决方案
#1
23
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
使用-Compress开关可以解决您的问题。我相信这是PowerShell中的一个错误。其他人与ex有类似的问题。包含双引号的值
#1
23
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
使用-Compress开关可以解决您的问题。我相信这是PowerShell中的一个错误。其他人与ex有类似的问题。包含双引号的值