Nested PowerShell-CustomObjects (JSON): Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „''How do I create a nested PowerShell custom object to store layers (nested) of information?'' <br> ''Use a hashtable with the PSCustomObject type accelerator,…“) |
Admin (Diskussion | Beiträge) K |
||
Zeile 13: | Zeile 13: | ||
} | } | ||
} | ConvertTo-Json | } | ConvertTo-Json | ||
− | </ | + | </source> |
Version vom 19. Dezember 2018, 11:03 Uhr
How do I create a nested PowerShell custom object to store layers (nested) of information?
Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key)
$JSON = [PSCustomObject]@{ Property1NameLayer1 = [PSCustomObject]@{ Property2NameLayer2 = [PSCustomObject]@{ Property3NameLayer3 = 'Property3Value' } Property4NameLayer2= 'Property2Value' Property5NameLayer2= 'Property3Value' } } | ConvertTo-Json