Skip to content

Instantly share code, notes, and snippets.

@bartenbach
Created December 27, 2018 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bartenbach/0c324b629914becd3feff36d3b2e6c36 to your computer and use it in GitHub Desktop.
Save bartenbach/0c324b629914becd3feff36d3b2e6c36 to your computer and use it in GitHub Desktop.
#!/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