I am extracting a JSON from a file using the following syntax:
$json = Get-Content $jsonfile | Out-String | ConvertFrom-Json
This is what my JSON currently looks like:
{
"Server": {
"CustomModules": [
"@{Name=Test Server Module 1; Tag=Server; Action=Option I want; Image_Path=C:Temp; Admin_Only=false}",
"@{Name=Test Server Module 2; Tag=Server; Action=Option I want; Image_Path=C:Temp/Downloads; Admin_Only=false}"
]
},
"Help Desk": {
"CustomModules": [
"@{Name=Test Help Desk Module 1; Tag=HD; Action=Option I want; Image_Path=C:Temp; Admin_Only=false}",
"@{Name=Test Help Desk Module 2; Tag=HD; Action=Option I want; Image_Path=C:Temp/Downloads; Admin_Only=true}"
]
}
}
How would I add another set of values under the Server 'CustomModules' so it looks like this?
"Server": {
"CustomModules": [
"@{Name=Test Server Module 1; Tag=Server; Action=Option I want; Image_Path=C:Temp; Admin_Only=false}",
"@{Name=Test Server Module 2; Tag=Server; Action=Option I want; Image_Path=C:Temp/Downloads; Admin_Only=false}",
"@{Name=Test Server Module 3; Tag=Server; Action=Option I want; Image_Path=C:/User/TestUser; Admin_Only=true}"
]
},
"Help Desk": {
"CustomModules": [
"@{Name=Test Help Desk Module 1; Tag=HD; Action=Option I want; Image_Path=C:Temp; Admin_Only=false}",
"@{Name=Test Help Desk Module 2; Tag=HD; Action=Option I want; Image_Path=C:Temp/Downloads; Admin_Only=true}"
]
}
}
I've tried Add-Member but it only adds to the current values already there.
@{Name=Test....}
? You will need to parse them after, I would recommend you to export them as real Json representations of the object