How to add square brackets to JSON variable?

I’m trying to add Work items to Azure DevOps from PowerShell via the REST API.
If I manually type in my JSON it works fine; for example:

$Body="[
{
"op": "add",
"path": "/fields/System.Title",
"value": "$($WorkItemTitle)"
}
]"

However if I try to use ConvertTo-JSON bby doing this:

$Body = @{
op = "add"
path = '/fields/System.Title'
value = $WorkItemTitle
}| ConvertTo-Json

Then my JSON looks deceptively similar:

{
"path": "/fields/System.Title",
"op": "add",
"value": "Test from Powershell"
}

But since the square brackets, [ & ], are missing, the JSON isn’t accepted by Azure DevOps. Add the brackets, and all is fine.
Obviously it is too much to ask for, that Microsoft would accept how PowerShell outputs JSON, so does anyone have a clever idea to how to add those brackets?
I would prefer to not have to type in JSON code as it is too easy to introduce arrors, and really, it just shows off another weakness in PowerShell -__-

Hah hah, I can see that PowerShell.org also doesn’t like JSON :wink:

Square brackets represent an array:

[pscustomobject]@{
    SomeProperty = 'Foo'
    AnotherProperty = @('Fe','Fi','Fum')
} | ConvertTo-Json

Output:

{
    "SomeProperty":  "Foo",
    "AnotherProperty":  [
                            "Fe",
                            "Fi",
                            "Fum"
                        ]
}

[quote quote=245322]Square brackets represent an array:

[pscustomobject]@{ SomeProperty = ‘Foo’ AnotherProperty = @(‘Fe’,‘Fi’,‘Fum’) } | ConvertTo-Json Output:

{ “SomeProperty”: “Foo”, “AnotherProperty”: [ “Fe”, “Fi”, “Fum” ] } [/quote]

Yes, that is correct, fortunately I found a solution on Reddit.