powershell v2.0 - Accessing values in an object resulting of a parsed JSON -
have following json (too big fit here), i'am not able value using
[system.reflection.assembly]::loadwithpartialname("system.web.extensions") $ser = new-object system.web.script.serialization.javascriptserializer $jsonobj = $ser.deserializeobject($json) $jsonobj.servers | where-object {$_.name -eq 'tendaji'} | ` select-object { $_.ipv4addr }
i receive
$_.ipv4address -------------- 113.55.212.113
how return 113.55.212.113
?
have :
$_.ipv4address | get-member get-member -inputobject $_.ipv4address
you may have array
$_.ipv4address[0]
be carreful you've got error inside json :
"name": "aboubacar""ipv4addr": "143.179.56.126"
should :
"name": "aboubacar", "ipv4addr": "143.179.56.126"
then
$jsonobj.servers[0].ipv4addr
gives
113.55.212.113
so in code can use :
($jsonobj.servers | where-object {$_.name -eq 'tendaji'}).ipv4addr
Comments
Post a Comment