active_directory icon indicating copy to clipboard operation
active_directory copied to clipboard

Let an array with a single entry be an array in JSON

Open j0le opened this issue 3 years ago • 0 comments

If the the "groups" property of the "user" object has only one entry, and we want to convert our list of users to JSON, then PowerShell doesn't create an array with a single entry as the value for the "group" property, but instead a scalar – a simple string.

The Problem is that PowerShell uses a default traversal depth of 2, if we use ConverTo-Json. We fix our issues by using a greater traversal depth with the Argument -Depth:100.

https://stackoverflow.com/questions/53583677/unexpected-convertto-json-results-answer-it-has-a-default-depth-of-2

j0le avatar Jun 18 '22 18:06 j0le