Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active August 10, 2023 13:48
Show Gist options
  • Save knbknb/6ee8c2bab9800e48b73c15c98eb70723 to your computer and use it in GitHub Desktop.
Save knbknb/6ee8c2bab9800e48b73c15c98eb70723 to your computer and use it in GitHub Desktop.
json | powershell
# display a JSON object as a table using PowerShell.
# the JSON is generated by a perl script
perl api-gfz.pl -r \
| pwsh -Command "$json = Get-Content -Raw -Stream; ConvertFrom-Json $json | Format-Table -AutoSize "
# with a Where-Object filter in between:
perl api-gfz.pl -r \
| pwsh -Command "$json = Get-Content -Raw -Stream; ConvertFrom-Json $json | Where-Object { \$_.status -eq 'paused' } | Format-Table -AutoSize "
# Assumes that the JSON structure is an array of objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment