如何摆脱“ConvertFrom-Json:无效的 JSON 原语”powershell 错误

如何摆脱“ConvertFrom-Json:无效的 JSON 原语”powershell 错误
  $FX_USER=$args[0]
  $FX_PWD=$args[1]
  $FX_JOBID=$args[2]
  $REGION=$args[3]
  $TAGS=$args[4]
  $SUITES=$args[5]
  $CATEGORIES=$args[6]
  $FX_HOST=$args[7]      

  $taskStatus="WAITING"
  Write-Host "taskStatus = " $taskStatus


 while ( ("$taskStatus" -eq "WAITING") -or ("$taskStatus" -eq "PROCESSING") ) 
           { 
    sleep 5
     Write-Host "Checking Status...."

             $passPercent=$(curl -k --header "Content-Type: application/json;charset=UTF-8" -X GET -u ""${FX_USER}":"${FX_PWD}"" ""${FX_HOST}"/api/v1/runs/${runId}" | jq -r '."data"|.ciCdStatus')


              $array =  $passPercent  | ConvertFrom-Json 

        $taskStatus="${array[0]}"
             Write-Host "task-status= $taskStatus"
             Write-Host "Status =" "${array[0]}" " Success Percent =" "${array[1]}"  " Total Tests =" "${array[2]}" " Time Taken =" "${array[4]}" " Run =" "${array[5]}"    

当我运行此 powershell 代码时,从控制台输出收到以下错误。

ConvertFrom-Json:无效的 JSON 原语:等待。在 C:\Users\Administrator\test.ps1:57 char:45 + $array = $passPercent | ConvertFrom-Json + ~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [ConvertFrom-Json],ArgumentException + FullyQualifiedErrorId:System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

状态 = 成功百分比 = 总测试次数 = 所用时间 = 运行 =

我应该在上面的字段(如 Status= Completed)后面的 = 符号后获取一些字符串或整数值,有人能帮我解决吗?很紧急。谢谢

相关内容