OS info
Edition: Windows 10 Enterprise
Version: 1607
OS Build: 14393.187
Installed RAM: 16.0 GB
System Type: 64-bit operating system, x64-based processor
Steps to reproduce
- Create a .json file. Write in an array with only one valid json object:
[{
"name": "Animals",
"age": "1",
"children": [{
"name": "mimi",
"age": "1",
"lovely": true,
"height": 20
},
{
"name": "dog",
"age": "2",
"lovely": false,
"height": 100
}]
}]
- Convert this json file content to psobject and then convert it back to write it to another file
$o=(Get-Content -Raw D:\Test_Convert.json | ConvertFrom-Json)
Set-Content 'D:\result.json' ($o | ConvertTo-Json)
- View the result.json:
{
"name": "Animals",
"age": "1",
"children": [
{
"name": "mimi",
"age": "1",
"lovely": true,
"height": 20
},
{
"name": "dog",
"age": "2",
"lovely": false,
"height": 100
}
]
}
Expected behavior
Get the right PSObject and write the same content back.
Actual behavior
The array turns into its only child.
Environment data
Included in the repro steps.
Powershell Version
PS C:\Users\qisun\Downloads\LatestPowerShell> $PSVersionTable.PSVersion
Major Minor Patch Label
----- ----- ----- -----
6 0 0 alpha
Have to mention that the issue does not repro when there are multiple children in that array.
OS info
Edition: Windows 10 Enterprise
Version: 1607
OS Build: 14393.187
Installed RAM: 16.0 GB
System Type: 64-bit operating system, x64-based processor
Steps to reproduce
[{ "name": "Animals", "age": "1", "children": [{ "name": "mimi", "age": "1", "lovely": true, "height": 20 }, { "name": "dog", "age": "2", "lovely": false, "height": 100 }] }]{ "name": "Animals", "age": "1", "children": [ { "name": "mimi", "age": "1", "lovely": true, "height": 20 }, { "name": "dog", "age": "2", "lovely": false, "height": 100 } ] }Expected behavior
Get the right PSObject and write the same content back.
Actual behavior
The array turns into its only child.
Environment data
Included in the repro steps.
Powershell Version
Have to mention that the issue does not repro when there are multiple children in that array.