I have an array of strings that I need to convert to array of objects.
Here is an example:
PS C:\Windows\system32> $datasets[0]
id : 11111
name : test1
addRowsAPIEnabled : False
configuredBy : xxxx
isRefreshable : True
isEffectiveIdentityRequired : False
isEffectiveIdentityRolesRequired : False
targetStorageMode : Abf
createdDate : 2019-02-12T16:43:01.047Z
contentProviderType : PbixInImportMode
upstreamDatasets : {}
users : {}
isInPlaceSharingEnabled : False
id : 22222
name : test2
addRowsAPIEnabled : False
configuredBy : xxxx
isRefreshable : True
isEffectiveIdentityRequired : False
isEffectiveIdentityRolesRequired : False
targetStorageMode : Abf
createdDate : 2019-07-15T15:53:15.057Z
contentProviderType : PbixInImportMode
upstreamDatasets : {}
users : {}
isInPlaceSharingEnabled : False
The datatype is String
PS C:\Windows\system32> $datasets[0].gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
As the final result, I would like to break down the elements of the nested arrays(that is string datatype now) by object and concatenate these into one general array.
I tried the approach suggested here
$datasets[0] -replace '(?<!:.*):', '=' | ConvertFrom-StringData
But I get an error about duplicate keys.
I also tried to convert from json $datasets[0] | ConvertFrom-Json
, but it throws an error.
Do you know a good approach in this case?