I try to include a dynamic array in a json variable and it fails.
hostsArray is dynamically built
# sample of hostsArray
* def hostsArray = '[{"hostid": "1234"},{"hostid": "4567"}, {"hostid": "9865"}]'
* def myjson =
"""
{
"key1": "val1",
"params" : {
"key2": "val2",
"hosts" : #(hostsArray)
}
"""
expected json:
{
"key1": "val1",
"params" : {
"key2": "val2",
"hosts" : [
{"hostid": "1234"},
{"hostid": "4567"},
{"hostid": "9865"}
]
}
I always got an error or a string, when using '#(hostsArray)' instead of the array structure
Is there a way to do that?
Thanks