trying to convert results

Welcome Forums General PowerShell Q&A trying to convert results

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 6 months ago.

  • Author
  • #33854

    Topics: 2
    Replies: 1
    Points: 0
    Rank: Member

    I am working on getting some information from a third party solution using a WebServices API. I can get the results, however, they are not in a format that I can use. I will post the results that I get so you can see it. I need a specific value out of the results. Currently I assign the results from the webrequest to a variable and when I read the contents of the variable I get the following which I have truncated for length of post.

    {"phoneNumber":5551234567,"totalCount":0,"messages":"","devices":{"device":{"@id":"1223","uuid":"6e822cb4-7be6-4b0e-b5aa-3b13dbe52ead","principal":"A00764","blockReason":0,"clientId":1073743052,"compliance":0,"countryCode":1,"countryId":183,"countryName":"United States","createdAt":"2015-08-27T19:53:16Z","currentPhoneNumber":"+

    If I use $result.devices I get the entire list of values in a single string. I need to specifically get the UUID from this result. It appears when I use ConvertFrom-json I get 4 properties, phoneNumber, totalCount, messages and devices. I need to get a piece of information out of devices. I tried to convert that to an array to no help. Any other thoughts on how to convert $result.devices into useable pieces of information?

  • #33860

    Topics: 6
    Replies: 653
    Points: 20
    Rank: Member

    You are on the right track, you just need get down to the property to output it.

    $data = '{"phoneNumber":5551234567,"totalCount":0,"messages":"","devices":{"device":{"@id":"1223","uuid":"6e822cb4-7be6-4b0e-b5aa-3b13dbe52ead","principal":"A00764","blockReason":0,"clientId":1073743052,"compliance":0,"countryCode":1,"countryId":183,"countryName":"United States","createdAt":"2015-08-27T19:53:16Z","currentPhoneNumber":"555-555-5555"}}}' | ConvertFrom-Json



The topic ‘trying to convert results’ is closed to new replies.