# How do I remove elements from in-memory JSON?

**URL:** <https://forums.powershell.org/t/how-do-i-remove-elements-from-in-memory-json/6671>\
**Category:** PowerShell Help\
**Created:** [June 20, 2016, 1:25pm UTC](https://forums.powershell.org/t/how-do-i-remove-elements-from-in-memory-json/6671 "2016-06-20T13:25:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregory-suvalian](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@gregory-suvalian](https://forums.powershell.org/u/gregory-suvalian)\
**Post date:** [June 20, 2016, 1:25pm UTC](https://forums.powershell.org/t/how-do-i-remove-elements-from-in-memory-json/6671/1 "2016-06-20T13:25:15Z")

</div>

Hello,

I have JSON which has collection of elements and I need to remove and element and then save JSON. I’m lost as far as what do I need to use to remove an element.

```
PS C:\windows\system32> $jsonFile.resourcePackages

resourcePackage                                                         
---------------                                                         
@{name=SynopticPanelBySQLBI1447436165337; type=0; items=System.Object[]}
@{name=YourVisual1465156444568; type=0; items=System.Object[]}          
@{name=BulletChartBySQLBI1459586236884; type=0; items=System.Object[]}  
@{name=CandleStickBySQLBI1458002061454; type=0; items=System.Object[]}  
@{name=SmartFilterBySQLBI1465232218990; type=0; items=System.Object[]}  
@{name=SmartFilterBySQLBI1465231403311; type=0; items=System.Object[]}  

PS C:\windows\system32> $jsonFile.resourcePackages.Remove(0)
Exception calling "Remove" with "1" argument(s): "Collection was of a fixed size."
At line:1 char:1
+ $jsonFile.resourcePackages.Remove(0)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotSupportedException
```

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [June 24, 2016, 11:05am UTC](https://forums.powershell.org/t/how-do-i-remove-elements-from-in-memory-json/6671/2 "2016-06-24T11:05:11Z")

</div>

If you’ve turned this into a proper object (ConvertFrom-Json), you could…

$json | where { $\_.whatever -eq ‘something’ } | convertto-json | out-file whatever.js

As a kind of basic approach. Use Where-Object to filter out the item(s) you don’t want.

---

<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:40pm UTC](https://forums.powershell.org/t/how-do-i-remove-elements-from-in-memory-json/6671/3 "2024-05-16T20:40:59Z")

</div>

Closed on May 16, 2024, 8:40pm UTC


