You can export the keys and values as plain text using Out-File
.
$json=@'
{
"variable1": "variable2",
"variable3": "variable4",
"variable5": "variable6"
}
'@|ConvertFrom-Json -AsHashtable
PS /~> $json
Name Value
---- -----
variable3 variable4
variable5 variable6
variable1 variable2
PS /~> $json.Keys
variable3
variable5
variable1
PS /~> $json.Values
variable4
variable6
variable2
Edit:
Credit to @Vivere, did not know -AsHashTable
was introduced on PS Core. Supposing the test is performed on PS 5.1 here is how to get the same result. If the JSON has more depth check out the link provided by him on comment below.
PS /~> $json=@'
{
"variable1": "variable2",
"variable3": "variable4",
"variable5": "variable6"
}
'@|ConvertFrom-Json
PS /~> $json.psobject.Properties.Name
variable1
variable3
variable5
PS /~> $json.psobject.Properties.Name|%{$json.$_}
variable2
variable4
variable6