RadhaKrishnaKiJaya
asked on
Extract the ID from a string
Hi Experts,
I have the following code.
After I run "data" contains the following string
I need help to extract all the IDs in a list or array.
For example, "1906.2302191.RT8CHwd45iRX Z", "1906.2302191.RT7kr6Nkhjk5 2"...
I am using C# and MVC
Thanks in advance!
I have the following code.
StreamReader reader = new StreamReader(response.GetResponseStream());
string data = reader.ReadToEnd();
After I run "data" contains the following string
"results": [{
"url": "https://www.zoo.com/api/chats/1906.2302191.RT8CHwd45iRXZ",
"timestamp": "2019-06-11T23:22:33Z",
"preview": "how can I add co workers to my account?\n",
"type": "offline_msg",
"id": "1906.2302191.RT8CHwd45iRXZ"
}, {
"url": "https://www.zoo.com/api/chats/1906.2302191.RT7kr6Nkhjk52",
"timestamp": "2019-06-11T21:33:34Z",
"preview": "I would like to order printer",
"type": "offline_msg",
"id": "1906.2302191.RT7kr6Nkhjk52"
}
}]
I need help to extract all the IDs in a list or array.
For example, "1906.2302191.RT8CHwd45iRX
I am using C# and MVC
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
powershelll
$json = '{
"results": [{
"url": "https://www.zoo.com/api/chats/1906.2302191.RT8CHwd45iRXZ",
"timestamp": "2019-06-11T23:22:33Z",
"preview": "how can I add co workers to my account?\n",
"type": "offline_msg",
"id": "1906.2302191.RT8CHwd45iRXZ"
}, {
"url": "https://www.zoo.com/api/chats/1906.2302191.RT7kr6Nkhjk52",
"timestamp": "2019-06-11T21:33:34Z",
"preview": "I would like to order printer",
"type": "offline_msg",
"id": "1906.2302191.RT7kr6Nkhjk52"
}
]}'
$data = @()
$data = (ConvertFrom-Json -InputObject $json) | Select-Object -ExpandProperty results | Select-Object id
$data
ASKER