We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ecb7431 commit 5e37d37Copy full SHA for 5e37d37
1 file changed
psutils/modules/string.psm1
@@ -108,12 +108,9 @@ function Convert-JsoncToJson {
108
$jsonContent = $jsonContent -replace ',\s*([}\]])', '$1'
109
110
# 转换内容为JSON对象以验证有效性
111
- try {
112
- $jsonContent | ConvertFrom-Json| Out-Null
113
- }
114
- catch {
+ if ( -not (Test-Json -Json $jsonContent -ErrorAction SilentlyContinue)) {
+ Write-Debug '目前7.5.0版本,Test-Json无法处理包含$schema的json'
115
Write-Error "转换失败: $_"
116
- return
117
}
118
119
# 输出结果
@@ -122,7 +119,7 @@ function Convert-JsoncToJson {
122
Write-Host "转换成功,结果已保存到: $OutputFilePath"
123
120
124
121
else {
125
- $jsonContent
+ $jsonContent
126
127
128
0 commit comments