I was intrigued with this example:
PS /home/nicholas>
PS /home/nicholas> $json = '[ { "hello": 1 } ]'
PS /home/nicholas> $json | ConvertFrom-Json | ConvertTo-Json
{
"hello": 1
}
PS /home/nicholas> $json | ConvertTo-Json | ConvertFrom-Json
[ { "hello": 1 } ]
PS /home/nicholas>
PS /home/nicholas> $json | ConvertFrom-Json | ConvertTo-Json
{
"hello": 1
}
PS /home/nicholas>
and am interested as to why it won't "round trip" correctly. Is it really any different? Seems a difference without distinction, perhaps.
Incidentally, what is powershell converting "from" and "to"? Help file says:
DESCRIPTION The
ConvertTo-Json
cmdlet converts any .NET object to a string in JavaScript Object Notation (JSON) format.
here, I suppose, String
.
I'm not seeing that any information is gained or lost in the above cycle. Perhaps I'm not understanding the concern.