# ConvertTo-Jason

**URL:** <https://forums.powershell.org/t/convertto-jason/5492>\
**Category:** PowerShell Help\
**Created:** [January 10, 2016, 9:32pm UTC](https://forums.powershell.org/t/convertto-jason/5492 "2016-01-10T21:32:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ofergenat](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@ofergenat](https://forums.powershell.org/u/ofergenat)\
**Post date:** [January 10, 2016, 9:32pm UTC](https://forums.powershell.org/t/convertto-jason/5492/1 "2016-01-10T21:32:01Z")

</div>

Hi All, (again 🙂 )  
I am trying to convert a cmdlet output after selecting a property and convert it to Jason.  
The problem is that I get all the data but each value gets the key beside it.  
I was expecting to have it grouped (in the jason format) so I get one property ‘Address’ and all the values, instead I get ‘Address’ duplicated.  
Can someone help please?

```
PS C:\Users\xxx> Get-NcNetInterface | select Address

Address
-------
169.254.231.133
169.254.32.182
169.254.214.116

PS C:\Users\xxx> Get-NcNetInterface | select Address | ConvertTo-Json
[
    {
        "Address": "169.254.231.133"
    },
    {
        "Address": "169.254.32.182"
    },
    {
        "Address": "169.254.214.116"
    }
]
```

Command without the convert:

```
PS C:\Users\xxx> Get-NcNetInterface | select Address

Address
-------
169.254.231.133
169.254.32.182
169.254.214.116
```

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [January 10, 2016, 9:42pm UTC](https://forums.powershell.org/t/convertto-jason/5492/2 "2016-01-10T21:42:23Z")

</div>

Its working as I would expect.

I don’t have the ONTAP toolkit on my machine but using Get-NetIPAddress gives similar results

PS\> Get-NetIPAddress -AddressFamily IPv4 | select IPAddress | ConvertTo-Json  
[  
{  
“IPAddress”: “127.0.0.1”  
},  
{  
“IPAddress”: “169.254.107.168”  
},  
{  
“IPAddress”: “169.254.76.205”  
},  
{  
“IPAddress”: “169.254.242.182”  
},  
{  
“IPAddress”: “10.10.54.200”  
},  
{  
“IPAddress”: “192.168.0.6”  
}  
]

Your command, and mine, produce a collection of objects. Each object is converted to JSON and added to the array of JSON objects.

So in your case the first object is converted to  
{  
“Address”: “169.254.231.133”  
}

---

<div class="post-metadata">

**Author:** ![ofergenat](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@ofergenat](https://forums.powershell.org/u/ofergenat)\
**Post date:** [January 11, 2016, 3:34am UTC](https://forums.powershell.org/t/convertto-jason/5492/3 "2016-01-11T03:34:02Z")

</div>

Hey Richard,  
Thanks for the reply.  
I understand the the convert is doing some sort of foreach for all the collection of objects.  
But in PowerShell console I can see the objects grouped to a table, I would like to select the column I want and have it converted to jason but keep the same format so I get one “Address” field with all the values it has (IPs).  
Can this be achieved?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:43pm UTC](https://forums.powershell.org/t/convertto-jason/5492/4 "2024-05-16T20:43:10Z")

</div>


