Ich versuche, das vollständige Objekt aus dem Array nicht ein Mitglied des Objekts zu entfernen. Ich bin nicht in der Lage, den Weg zum Entfernen des Objekts zu finden, gibt es so viele Lösungen verfügbar, um das Element zu entfernen. Kann jemand bitte einen Weg vorschlagen, das komplette Objekt zu entfernen.Wie entfernt man ein Objekt aus dem Array in der Power Shell?
JSON Data: JSON data stored in the file.
{
"data": [
{
"id": "Caption",
"firstname": "Caption",
"lastname": "test",
"email": "test",
"requester": "test",
"password": "test",
"incNumber": "test"
}
]
}
Code : I have written the following code to read the object from the array and store into variables to do the task.Once the task is completed I want to remove the object from the array.
$file = Get-Content '\path\to\file' -Raw | ConvertFrom-Json
$file.data | % {if($_.id -eq 'Caption'){
$1 = $_.id
Write-Host $1
###Here I want to remove the whole object related to the id
}}
'$ file.data = $ file.data | ? id -ne 'Caption'' – wOxxOm