FlattenObjects Parameter (Connect-JSON Cmdlet)
Specifies whether object properties are flattened into individual columns.
Syntax
Connect-JSON -FlattenObjects bool
Data Type
bool
Default Value
true
Remarks
When this property is set to true, the cmdlet flattens object properties into separate columns. The column name is generated by concatenating the parent object name and property name with a dot separator.
When this property is set to false, objects nested within arrays are returned as JSON strings instead of flattened columns.
The following example shows how nested objects are flattened at connection time:
[
{ "grade": "A", "score": 2 },
{ "grade": "A", "score": 6 },
{ "grade": "A", "score": 10 },
{ "grade": "A", "score": 9 },
{ "grade": "B", "score": 14 }
]
When FlattenObjects is set to true and FlattenArrays is set to 1, the array above is flattened into the following table:
| Column Name | Column Value |
| grades.0.grade | A |
| grades.0.score | 2 |
Flattening objects simplifies querying nested data but can increase the number of columns when applied to deeply nested structures.
This property is useful for controlling how nested objects are represented in flattened JSON data models.