Last active
June 2, 2020 19:53
-
-
Save btipling/ee096da8b794deab6d621bf9b8ec41c4 to your computer and use it in GitHub Desktop.
Just some JSON to parse.
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
{ | |
"foo": 3, | |
"bar": 10 | |
} |
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
PS C:\Users\swart\projects\powershell_scripts> .\get_remote_data.ps1 | |
PS C:\Users\swart\projects\powershell_scripts> Find-RemoteData -Name "bar" | |
10 | |
PS C:\Users\swart\projects\powershell_scripts> Find-RemoteData -Name "foo" | |
3 | |
PS C:\Users\swart\projects\powershell_scripts> (Find-RemoteData -Name "bar") + (Find-RemoteData -Name "foo") | |
13 | |
PS C:\Users\swart\projects\powershell_scripts> Read-RemoteData | |
foo bar | |
--- --- | |
3 10 |
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
$global:dataURL = "https://gist.githubusercontent.com/btipling/ee096da8b794deab6d621bf9b8ec41c4/raw/d46f89efa3059c1e3915dafe5b438f4e41bcf859/foo.json" | |
function global:Read-RemoteData() { | |
Invoke-RestMethod -Uri $global:dataURL | |
} | |
function global:Find-RemoteData([string]$Name) { | |
$response = Invoke-WebRequest -Uri $global:dataURL | |
$data = $response.Content | ConvertFrom-Json -AsHashtable | |
[int] $data[$Name] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment