Created
December 27, 2018 02:28
-
-
Save bartenbach/0c324b629914becd3feff36d3b2e6c36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/pwsh | |
# helper to turn PSCustomObject into a list of key/value pairs | |
function Get-ObjectMembers { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$True, ValueFromPipeline=$True)] | |
[PSCustomObject]$obj | |
) | |
$obj | Get-Member -MemberType NoteProperty | ForEach-Object { | |
$key = $_.Name | |
[PSCustomObject]@{Key = $key; Value = $obj."$key"} | |
} | |
} | |
$json = (Get-Content -Path './package-lock.json') -join "`n" | |
$json | ConvertFrom-Json | Get-ObjectMembers | foreach { | |
$_.Value | Get-ObjectMembers | foreach { | |
write-host "key: " $_.key "value: " $_.value.resolved | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment