Skip to content
Discussion options

You must be logged in to vote

Nested looping is not possible but using map() you can create the desired outcome:

var test = [
  {
    name: 'name'
    products: [
      1
      2
    ]
  }
]

var productByName = [for item in test: map(item.products, product => {
  name: item.name
  product: product
})]

output testFlatten array = flatten(productByName)

testFlatten resolves to the following array:

[{"name":"name","product":1},{"name":"name","product":2}]

Which you can then loop over with the items() function.

Also I would not rely on ChatGPT for anything bicep related. If Github copilot which uses real repositories as a data source can't get it right most of the time, a LLM that confidently spits false information is …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@nerdiculous
Comment options

Answer selected by housten
Comment options

You must be logged in to vote
1 reply
@GABRIELNGBTUC
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants