hello,
I am getting response output from Postman as -
{
Result :
{
Id : 1,
Name : Ramesh,
Designation : Manager
}
}
So in my mvc web api project, I'm getting Result , but i want separate property of it, something like :
HCOutput output = New HCOutput();
var aa = output.Result.Name;
output.Result.Id;
so how it can be done? is it serialization ?
Naimish MakwanaPosted Feb 3, 2023, 5:11 PM
Hello Sushant
Try below code as you want.
then
Thanks.
Naimish MakwanaPosted Feb 3, 2023, 4:52 PM
Hello Sushant,
You need to create class like below.
Then
Thanks
Naimish
Sushant TorankarPosted Feb 3, 2023, 4:35 PM
Thank you Naimish Makwana for reply
Result is a already Object in my Class clsResponse
public class Result
{
public string status{ get; set; }
public string error{ get; set; }
public Object Result{ get; set; }
}
I'm getting response in my Object Result
{
status : "success",
error : "",
Result :
{
Id : 1,
Name : Ramesh,
Designation : Manager
}
}
, i have to then get Id or Name or Designation separately
Naimish MakwanaPosted Feb 3, 2023, 3:32 PM
Hello Sushant,
You need to create below class which will parse the response:
You can than Deserialize respones as below.
Thanks
Naimish