easitab / EPR.GlobalFunctions

Provide functions to be used in script executed by EasitProcessRunner
https://docs.easitgo.com/techspace/epr/globalfunctions/
Apache License 2.0
1 stars 0 forks source link

Add function to convert exported object to "flat" PSCustomObject #22

Closed easitab-owner closed 8 months ago

easitab-owner commented 10 months ago

Instead of having to do this:

$exportObject = $StringInput | ConvertFrom-Json $itemToImport = $exportObject.itemToImport[0] foreach ($item in $itemToImport) { $properties = $item.property $customObject = New-Object PSObject foreach ($property in $properties) { $customObject | Add-Member -MemberType NoteProperty -Name $property.name -Value $property.content }

We should offer a way to do something like this:

Convert-ExportedEasitGOObject -ExportedJson $StringInput That should result in a object that you can call each property specified in the export configuration like this: $convertedObject.propertyname In the case of an collection, $convertedObject.propertyname would be an array of values. We should keep, or copy, the property property from the StringInput to the new PSCustomObject.