I'm trying to convert data to JSON as input for a REST API. The challenge I have is that the data should consist of multiple depths (For a lack of better words). The code I'm using now is:
(@{name = "Contoso"; all_assets = "false"; all_users="false"; rules= @{type="fqdn"; operator="match"; terms=@("contoso") } }| ConvertTo-Json)
the output now is:
{
"all_users": "false",
"name": "Contoso",
"all_assets": "false",
"rules": {
"operator": "match",
"terms": [
"contoso"
],
"type": "fqdn"
}
}
The REST-Api is complaining that the data contains invalid characters. Looking at the output, the section "rules:" contains { } instead of [ ]. I've been trying all kinds of tricks but I can't seem to figure this one out.
Anyone know what I'm doing wrong here?