Stringifying an array of objects results in an error when its value is passed to another module
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
0.4.1272
**Describe the bug**
Stringifying a locally defined array of objects results in an error about '{' being unexpected. Providing the array through a module does work.
**To Reproduce**
Steps to reproduce the behavior:
```bicep
var myArray = [
{
id: '117'
name: 'John'
}
]
// The module takes a string parameter called 'value'
module tst 'modules/sample-module.bicep' = {
name: 'tst'
params: {
value: string(myArray)
}
}
```
Error is:
```
{'code': 'InvalidTemplate', 'message': 'Deployment template language expression evaluation failed: \'The language expression \'{"id":"117","name":"John"}\' is not valid: the string character \'{\' at position \'0\' is not expected.\'. Please see https://aka.ms/arm-template-expressions for usage details.', 'additionalInfo': [{'type': 'TemplateViolation', 'info': {'lineNumber': 0, 'linePosition': 0, 'path': ''}}]}
```
However, if myArray is part of the output from another module, it does work as expected. So as a workaround I have a, pretty much, empty module returning an array of objects.
**Additional context**
I'm trying to store an array of JSON objects in an App Configuration resource with the application/json content-type.
Contributor guide
Assessment
This issue has not been assessed yet.