I have a JSON file with configurations that I use to determine what properties I need to call on an object.
Since PowerShell allows using a string variable as property this works fine like so:
$config = Get-Content .\syncProperties.json -Raw | ConvertFrom-Json
$myPropertyFromJSON = $config.profileMappings[0].sourceField
echo $myObject.$myPropertyFromJSON
however sourceField can be a sub-property like "SomeProperty.SubProperty" and this of course does not work.
What would be a nice generic way to handle properties/sub-properties from JSON (read: I dont want to do some nasty replacing or splitting)
Sample JSON:
{
"profileMappings": [
{
"source": "AzureRm",
"sourceField": "ExtensionProperty.extension_xyz_countryCode",
"destinationField": "countryCode"
},
{
"source": "AzureRm",
"sourceField": "Department",
"destinationField": "companyName"
},
{
"source": "EXO",
"sourceField": "CustomAttribute1",
"destinationField": "BuildingNo"
}
]
}