When writing a powershell script with a ConvertFrom-Json, it seems that values in arrays are converted with additional spaces when casting them to a string. The following code shows this in a small code sample:
$object = @"
{
"object":
{
"prop1": "value",
"array":[
{ "key": "value"},
{ "key2": "valuevalue"},
{ "key3": "valuevalue"},
{ "key4": "valuevalue"},
{ "key5": "valuevalue"}
]
}
}
"@ | ConvertFrom-Json
$object.object.prop1
$object.object.array.key
$t = $object.object.prop1
$t2= $object.object.array.key
"""$t"""
"""$t2"""
Output:
value
value
"value"
"value "
Where are the extra spaces coming from in the last value? When adding more value pairs to the array, more spaces are added.