I am using powershell to explore a REST API. I discovered a strange anomaly. When I serialize/descrialize the following objct, the responses
object are gone! I have verified that it is all still in tact when converted to .net object, so the problem happens when converting from .net object to JSON.
$json = @'
{
"stubs": [
{
"responses": [
{
"is": {
"body": "54"
}
},
{
"is": {
"body": "21"
}
},
{
"is": {
"body": "0"
}
}
]
}
]
}
'@
$json | ConvertFrom-Json | ConvertTo-Json
The result form the above conversion is this:
{
"stubs": [
{
"responses": " "
}
]
}
If I run this, I receive 54, as expected:
$json | ConvertFrom-Json | %{ $_.stubs.responses[0].is.body }
I am running on Ubuntu, but don't believe that should make a difference. This should be easy to verify for someone on Windows.