本帖最后由 5i365 于 2022-5-15 09:06 编辑
下面的代码, 是用一行字符串来表达的json的, 不太好观察结构!
我想把它改成 hash表+函数的方式, 在frames[]处卡壳了, 求高手指引, 提前感谢!
原代码:- $BuildName = 'he'
- $Message = 'bei'
- $Payload = '{"priority":"critical","icon_type":"alert","lifeTime":2000,"model":{"frames":[{"icon":"555","text":"' + $BuildName + ' BUILD FAILED! ' + $Message + '"}],"sound":{"category":"alarms","id":"alarm6","repeat":2},"cycles":0}}'
- $Payload
复制代码 我的代码:- $Payload = @{
- "priority" = "critical"
- "icon_type" = "alert"
- "lifeTime" = 2000
- "model" = @{
- "frames" = "卡这里了"
- "sound" = @{
- "category" = "alarms"
- "id" = "alarm6"
- "repeat" = 2
- }
- "cycles" = 0
- }
- } | ConvertTo-Json
- $Payload
复制代码
|