Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Can see values from parsed JSON object, but they present as null on PSv2

$
0
0

Code:

[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") | out-null
$web_client = new-object system.net.webclient
$npi="randomNPInumberfromNPPES"
$jsondownload = "https://npiregistry.cms.hhs.gov/api/?number=" + $npi
$build_info=$web_client.DownloadString($jsondownload)
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$obj = $ser.DeserializeObject($build_info)
#$obj.results.basic.name
Write-Host "Taxonomies for" $npi
$obj.results.taxonomies.code

(of course, it needs a real NPI number, but that's it)

When I am on my Windows 10 workstation at home with PS5, I can access and call all the elements of the deserialized JSON. When I am on my Windows 7 workstation at work with PS2, I cansee them, but nothing returns when I call them directly.

$obj.results

                                                                                          

Key                Value                                                                                                   
---                -----                                                                                                   
taxonomies         {System.Collections.Generic.Dictionary`2[System.String,System.Object]}                                   
addresses          {System.Collections.Generic.Dictionary`2[System.String,System.Object], System.Collections.Generic.Dict...
created_epoch      1196294400                                                                                              
identifiers        {}                                                                                                      
other_names        {}                                                                                                      
number             randomNPInumberfromNPPES                                                                                              
last_updated_epoch 1387411200                                                                                              
basic              {[status, A], [credential, ANP], [first_name, FakeFirstName], [last_name, FakeLastName]...}                             
enumeration_type   NPI-1        

On my Windows 10 PSv5, I can call $obj.results.created_epoch and 1196294400 returns. I do the exact same thing on the W7 PSv2 desktop, andwhile I can still see it (see above paste) when I do $obj.results, when I do $obj.results.created_epoch, no value returns.

I'm losing my mind - I was so happy when I figured out that my PSv2 could use System.Web.Extensions so I could parse JSON, but now I'm really lost. It's maddening because I can see the results on both installations, but can only access the actual values in v5. I've searched everywhere and I can't find a solution - I'm sure it's something ridiculous.

Please help :(


Viewing all articles
Browse latest Browse all 21975

Trending Articles