azure-resource-manager - 如何反序列化 JSON 数组?
问题描述
我正在尝试在 DevTest Lab 中向 VM 添加工件,并且我想动态传递工件名称。下面是我的参数
"Artifacts": {
"type": "array"
},
在资源部分我称之为
"artifacts":["[parameters('Artifacts')]"]
我从 powershell 文件中调用这个 ARM 如下
$sampleJob += Start-Job -Name $fileName -FilePath $scriptlocation -ArgumentList $artifact
$artifact 被定义为对象类型 Object[]
运行脚本时出现以下错误。
"message": "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Microsoft.DevTestLab.VirtualMachine.Data.Models.Rest.ArtifactInstallProperties' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.
如何解决上述错误。任何帮助都将不胜感激。谢谢你。
解决方案
在“资源”部分中,删除外部的一对方括号。它应该看起来像:
"artifacts": "[parameters('Artifacts')]"
推荐阅读
- c# - WPF:绑定到网格的“HorizontalAlignment”属性
- swiftui - 关闭视图swiftui时键盘关闭无法正常工作
- javascript - 如何基于枚举为 .reduce 创建初始值?
- r - 计算数据框相似行
- css - SVG动画不会彼此播放
- protocol-buffers - 跨微服务共享原始文件或生成的文件
- prometheus - 配置警报管理器以使用传入的 web-hook 将通知推送到我的 ring central (glip) 应用程序
- android - 连接查询时重命名列失败
- range - 由于错误,无法运行程序来更改定义的名称
- android - Android OkHttpClient - 使用 Kotlin 下载文件