I am having problems getting assembling this Json in Powershell
{
"totalCount": 1,
"list": [
{
"type": "ToggleLightingState",
"order": 1,
"delay": null,
"postDelay": null,
"name": "Toggle lighting state of light L-17E-611-KB-1",
"parameters": {
"relayIds": [],
"curveType": null,
"behavior": null,
"duration": null,
"useAssignedSpace": false,
"spaceIds": [],
"lightIds": [
2408
],
"spaceGroupIds": []
}
}
]
}
I am Iterating through an array using a for loop to fill in the values. I am just struggling to generate a list inside a list in JSON
$ActionList = @{
@(
@{
type = 'ToggleLightingState'
order = 1
delay = 'null'
postDelay = 'null'
name = $actionSets[$i][0]
}
)
}
ConvertTo-Json -InputObject $ActionList
You don't have the name of the array "list" inside the object. It looks like you can't have an unnamed array inside an object. I don't know what $actionsets is, so I took off the indexes. Plus fixing your syntax errors results in the below. Note that 'null' and $null are different things.