Hi counterkin,
Create a class and after recieving the response deserialize to get get the values.
Refer below code.
HTML
<table>
<tr>
<td>Id:</td>
<td>
<asp:Label ID="lblId" runat="server" /></td>
</tr>
<tr>
<td>Result Id:</td>
<td>
<asp:Label ID="lblResultId" runat="server" /></td>
</tr>
<tr>
<td>User Id:</td>
<td>
<asp:Label ID="lblUserId" runat="server" /></td>
</tr>
</table>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string response = "{\"id\": \"9527\",\"result_id\": \"1\",\"user_id\": \"M3302\"}";
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
Root result = js.Deserialize<Root>(response);
lblId.Text = result.id.ToString();
lblResultId.Text = result.result_id.ToString();
lblUserId.Text = result.user_id.ToString();
}
public class Root
{
public int id { get; set; }
public int result_id { get; set; }
public string user_id { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim response As String = "{""id"": ""9527"",""result_id"": ""1"",""user_id"": ""M3302""}"
Dim js As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim result As Root = js.Deserialize(Of Root)(response)
lblId.Text = result.id.ToString()
lblResultId.Text = result.result_id.ToString()
lblUserId.Text = result.user_id.ToString()
End Sub
Public Class Root
Public Property id As Integer
Public Property result_id As Integer
Public Property user_id As String
End Class
Screenshot
Id: |
9527 |
Result Id: |
1 |
User Id: |
M3302 |