Extract data from string file returned from System.Net.WebClient
i'm using powershell send sms through sms gateway provider. the sending works great last line of code:
$wc.downloadstring($url) | out-file c:\result.txt
result.txt looks this:
{
"message-count": "1",
"messages": [{
"to": "11234567899",
"message-id": "0d0000001b0ab5ed",
"status": "0",
"remaining-balance": "1.92020000",
"message-price": "0.00570000",
"network": "310004"
}]
}
the part care status in case it's zero, two-digit number. i'd extract value of status line , put in it's own file called r.txt with r.txt containing 0
is possible , if me pointed in right direction.
thanks,
kevin
$return = '{ "message-count": "1", "messages": [{ "to": "11234567899", "message-id": "0d0000001b0ab5ed", "status": "0", "remaining-balance": "1.92020000", "message-price": "0.00570000", "network": "310004" }] }' ($return | convertfrom-json).messages.status \_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment