ConsoleGuiTools
ConsoleGuiTools copied to clipboard
Fix #242 - Adds support for PSCustomObject
trafficstars
PR Summary
Adds support for dealing with native PSObject instances (current code only deals with native object types).
- Extracts nested 'cached member' classes to seperate files
- Adds interface and abstract base
- Adds implementation for PSObject properties
Fixes #242
Test JSON
$Values = @'
{
"Candidate":
{
"Name": {
"3rd": "Surname",
"1st": "Forename",
"2nd": "Middle name"
},
"Date of Birth": "+1582-10-15",
"E-mail Address": "mailTo:[email protected]",
"Mobile Telephone Number": "tel:+00-0000-000000",
"Blood Group": "" // Unknown
},
"Mother":
{
"Name": {
"3rd": "Surname",
"1st": "Forename",
"2nd": "Middle name"
},
"Date of Birth": "+1582-10-15",
"E-mail Address": "mailTo:[email protected]",
"Mobile Telephone Number": "tel:+00-0000-000000",
},
"Father":
{
"Name": {
"3rd": "Surname",
"1st": "Forename",
"2nd": "Middle name"
},
"Date of Birth": "+1582-10-15",
"E-mail Address": "mailTo:[email protected]",
"Mobile Telephone Number": "tel:+00-0000-000000",
},
}
'@
Test JSON 2
Test JSON 2 loaded in Show-ObjectTree
$Values = @'
{
"name": "Root",
"value": "Root Value",
"children": [
{
"name": "Child 1",
"value": "Child 1 Value",
"children": [
{
"name": "Grandchild 1",
"value": "Grandchild 1 Value",
"children": [
{
"name": "Great-Grandchild 1",
"value": "Great-Grandchild 1 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
},
"relatedObjects": [
{
"id": 123,
"name": "Related Object 1"
},
{
"id": 124,
"name": "Related Object 2"
}
]
},
{
"name": "Great-Grandchild 2",
"value": "Great-Grandchild 2 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
},
"relatedObjects": [
{
"id": 125,
"name": "Related Object 3"
}
]
}
]
},
{
"name": "Grandchild 2",
"value": "Grandchild 2 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
}
}
]
},
{
"name": "Child 2",
"value": "Child 2 Value",
"children": [
{
"name": "Grandchild 3",
"value": "Grandchild 3 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
}
},
{
"name": "Grandchild 4",
"value": "Grandchild 4 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
}
}
],
"arrayProperty": [1, 2, 3, 4]
},
{
"name": "Child 3",
"value": "Child 3 Value",
"attributes": {
"attribute1": "Value1",
"attribute2": "Value2"
},
"arrayProperty": ["a", "b", "c"]
}
]
}
'@
How to manually test with the above JSON
Invoke-Build Build -ModuleName Microsoft.PowerShell.ConsoleGuiTools
pwsh
import-Module ./module/Microsoft.PowerShell.ConsoleGuiTools
$Values = @'
{
...
}
'@
$Values | ConvertFrom-JSON | Show-ObjectTree
A new pwsh window is launched to avoid conflict of modules. Exit after test with exit.