You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| object |Yes |object |The dictionary object to convert to an array. |
420
-
421
-
### Return value
422
-
423
-
An array of objects for the converted dictionary. Each object in the array has a `key` property that contains the key value for the dictionary. Each object also has a `value` property that contains the properties for the object.
424
-
425
-
### Example
426
-
427
-
The following example converts a dictionary object to an array. For each object in the array, it creates a new object with modified values.
428
-
429
-
```bicep
430
-
var entities = {
431
-
item002: {
432
-
enabled: false
433
-
displayName: 'Example item 2'
434
-
number: 200
435
-
}
436
-
item001: {
437
-
enabled: true
438
-
displayName: 'Example item 1'
439
-
number: 300
440
-
}
441
-
}
442
-
443
-
var modifiedListOfEntities = [for entity in items(entities): {
The following example shows the array that is returned from the items function.
473
-
474
-
```bicep
475
-
var entities = {
476
-
item002: {
477
-
enabled: false
478
-
displayName: 'Example item 2'
479
-
number: 200
480
-
}
481
-
item001: {
482
-
enabled: true
483
-
displayName: 'Example item 1'
484
-
number: 300
485
-
}
486
-
}
487
-
488
-
var entitiesArray = items(entities)
489
-
490
-
output itemsResult array = entitiesArray
491
-
```
492
-
493
-
The example returns:
494
-
495
-
```json
496
-
"itemsResult": {
497
-
"type": "Array",
498
-
"value": [
499
-
{
500
-
"key": "item001",
501
-
"value": {
502
-
"displayName": "Example item 1",
503
-
"enabled": true,
504
-
"number": 300
505
-
}
506
-
},
507
-
{
508
-
"key": "item002",
509
-
"value": {
510
-
"displayName": "Example item 2",
511
-
"enabled": false,
512
-
"number": 200
513
-
}
514
-
}
515
-
]
516
-
}
517
-
```
518
-
519
-
The items() function sorts the objects in the alphabetical order. For example, **item001** appears before **item002** in the outputs of the two preceding samples.
0 commit comments