in src/PSRule.Rules.Azure/Data/Template/TemplateVisitor.cs [1759:1789]
private static JToken ResolveVariable(ITemplateContext context, TypePrimitive primitive, JToken value)
{
if (value is JObject jObject)
{
foreach (var copyIndex in GetVariableIterator(context, jObject))
{
if (copyIndex.IsCopy())
{
context.CopyIndex.Push(copyIndex);
var jArray = new JArray();
while (copyIndex.Next())
{
var instance = copyIndex.CloneInput<JToken>();
jArray.Add(ResolveToken(context, instance));
}
jObject[copyIndex.Name] = jArray;
context.CopyIndex.Pop();
}
}
return ResolveToken(context, jObject);
}
else if (value is JArray jArray)
{
return ExpandArray(context, jArray);
}
else if (value is JToken jToken && jToken.Type == JTokenType.String)
{
return ExpandPropertyToken(context, primitive, jToken);
}
return value;
}