Skip to content

Commit fb8295d

Browse files
authored
Deserialized the Value in DeploymentVariable as object array if its type is Array (#16675)
* Deserialized the Value in DeploymentVariable as object array if its type is Array * finish code
1 parent 672c6d1 commit fb8295d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Resources/ResourceManager/SdkExtensions/ResourcesExtensions.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ public static string ConstructDeploymentVariableTable(Dictionary<string, Deploym
256256

257257
foreach (KeyValuePair<string, DeploymentVariable> pair in dictionary)
258258
{
259-
result.AppendFormat(rowFormat, pair.Key, pair.Value.Type, pair.Value.Value.ToString().Indent(maxNameLength + maxTypeLength + 4).Trim());
259+
result.AppendFormat(rowFormat, pair.Key, pair.Value.Type,
260+
JsonConvert.SerializeObject(pair.Value.Value).Indent(maxNameLength + maxTypeLength + 4).Trim());
260261
}
261262
}
262263

@@ -317,12 +318,26 @@ private static void SetDeploymentProperties(PSDeploymentObject deploymentObject,
317318
if (properties.Outputs != null)
318319
{
319320
Dictionary<string, DeploymentVariable> outputs = JsonConvert.DeserializeObject<Dictionary<string, DeploymentVariable>>(properties.Outputs.ToString());
321+
// Continue deserialize if the type of Value in DeploymentVariable is array
322+
outputs?.Values.ForEach(dv => {
323+
if ("Array".Equals(dv?.Type))
324+
{
325+
dv.Value = JsonConvert.DeserializeObject<object[]>(dv.Value.ToString());
326+
}
327+
});
320328
deploymentObject.Outputs = outputs;
321329
}
322330

323331
if (properties.Parameters != null)
324332
{
325333
Dictionary<string, DeploymentVariable> parameters = JsonConvert.DeserializeObject<Dictionary<string, DeploymentVariable>>(properties.Parameters.ToString());
334+
// Continue deserialize if the type of Value in DeploymentVariable is array
335+
parameters?.Values.ForEach(dv => {
336+
if ("Array".Equals(dv?.Type))
337+
{
338+
dv.Value = JsonConvert.DeserializeObject<object[]>(dv.Value.ToString());
339+
}
340+
});
326341
deploymentObject.Parameters = parameters;
327342
}
328343

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Deserialized the `Value` in `DeploymentVariable` as object array if its type is Array [#16523]
2223
* Fixed the usage of SignInName in New-AzRoleAssignment [#16627]
2324
* Formatted the output format of DeploymentVariable
2425
* Remove isUser operation filter from GetAzureProviderOperation Cmdlet

0 commit comments

Comments
 (0)