Skip to content

Commit 63b4ff6

Browse files
authored
[Resources] Fix array parameter serialization issue (#12805)
* Fix array serialization issue and add tests * Make test more robust * Update change log
1 parent 5ed292c commit 63b4ff6

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

src/Resources/ResourceManager/Json/PSJsonSerializer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ private static object ProcessValue(object value, int currentDepth, SerializeCont
8484
return value;
8585
}
8686

87+
if (value is JValue jValue)
88+
{
89+
return jValue.Value<object>();
90+
}
91+
8792
if (value is JObject jObject)
8893
{
8994
return jObject.ToObject<Dictionary<object, object>>();

src/Resources/Resources.Test/Json/PSJsonSerializerTests.cs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,25 @@ public void Serialize_Hashtable_Success()
6666
["bar"] = true,
6767
["nested"] = new Hashtable
6868
{
69-
["foo"] = new PSObject(Guid.Parse("4d44fe86-f04a-4ba5-9900-abdec8cb11c1"))
69+
["foo"] = new PSObject(Guid.Parse("4d44fe86-f04a-4ba5-9900-abdec8cb11c1")),
70+
["bar"] = new object[]
71+
{
72+
"test",
73+
true,
74+
123,
75+
new Hashtable
76+
{
77+
["deepNested"] = new PSObject("leaf"),
78+
["array"] = new object[]
79+
{
80+
new PSObject("abc"),
81+
new PSObject(new
82+
{
83+
stuff = false
84+
})
85+
}
86+
}
87+
}
7088
}
7189
};
7290

@@ -79,7 +97,25 @@ public void Serialize_Hashtable_Success()
7997
bar = true,
8098
nested = new
8199
{
82-
foo = "4d44fe86-f04a-4ba5-9900-abdec8cb11c1"
100+
foo = "4d44fe86-f04a-4ba5-9900-abdec8cb11c1",
101+
bar = new object[]
102+
{
103+
"test",
104+
true,
105+
123,
106+
new
107+
{
108+
deepNested = "leaf",
109+
array = new object[]
110+
{
111+
"abc",
112+
new
113+
{
114+
stuff = false
115+
}
116+
}
117+
}
118+
}
83119
}
84120
});
85121
Assert.True(JToken.DeepEquals(expected, parsedResult));

src/Resources/Resources/ChangeLog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21-
* Added breaking change attribute to `SubscriptionId` parameter of `Get-AzResourceGroupDeploymentOperation`.
22-
* Updated ARM template What-If cmdlets to show "Ignore" resource changes last.
23-
* Fixed an issue where dynamic secure string parameters for deployment cmdlets are not correctly serialized.
21+
* Added breaking change attribute to `SubscriptionId` parameter of `Get-AzResourceGroupDeploymentOperation`
22+
* Updated ARM template What-If cmdlets to show "Ignore" resource changes last
23+
* Fixed secure and array parameter serialization issues for deployment cmdlets [#12773]
2424

2525
## Version 2.5.0
2626
* Updated `Get-AzPolicyAlias` response to include information indicating whether the alias is modifiable by Azure Policy.

0 commit comments

Comments
 (0)