diff --git a/source/nodejs/adaptivecards-designer/src/data.ts b/source/nodejs/adaptivecards-designer/src/data.ts index 0fa0ed0fff..634430737e 100644 --- a/source/nodejs/adaptivecards-designer/src/data.ts +++ b/source/nodejs/adaptivecards-designer/src/data.ts @@ -302,9 +302,17 @@ export class FieldDefinition { let forceIndexerSyntax: boolean = false; for (let i = path.length - 1; i >= 0; i--) { - let qualifiedName = path[i].qualifiedName(false) + let qualifiedName = path[i].qualifiedName(false); - if (shouldUseIndexerSyntax(qualifiedName) || forceIndexerSyntax) { + let modifiedName = qualifiedName; + + // If we include `[0]` in the qualified name while determining if we should use indexer syntax, + // We could incorrectly wrap the name in [] + if (path[i].dataType instanceof ArrayData && qualifiedName.endsWith("[0]")) { + modifiedName = qualifiedName.substring(0, qualifiedName.length - 3); + } + + if (shouldUseIndexerSyntax(modifiedName) || forceIndexerSyntax) { qualifiedName = "['" + qualifiedName + "']"; forceIndexerSyntax = true;