Hi nauna,
Refer below sample code.
C#
protected void Page_Load(object sender, EventArgs e)
{
System.IO.StreamReader stRead = new System.IO.StreamReader(Server.MapPath("json.json"));
RootObject root = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(stRead.ReadToEnd());
Response.Write(string.Format("Order Id : <b>{0}</b>", root.order.id));
}
public class RootObject
{
public string id { get; set; }
public Order order { get; set; }
public Tender tender { get; set; }
public decimal amount { get; set; }
public decimal taxAmount { get; set; }
public decimal cashbackAmount { get; set; }
public Employee employee { get; set; }
public string createdTime { get; set; }
public string clientCreatedTime { get; set; }
public string modifiedTime { get; set; }
public bool offline { get; set; }
public string result { get; set; }
public string externalReferenceId { get; set; }
}
public class Order
{
public string id { get; set; }
}
public class Tender
{
public string href { get; set; }
public string id { get; set; }
}
public class Employee
{
public string id { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim stRead As IO.StreamReader = New IO.StreamReader(Server.MapPath("json.json"))
Dim root As RootObject = Newtonsoft.Json.JsonConvert.DeserializeObject(Of RootObject)(stRead.ReadToEnd())
Response.Write(String.Format("Order Id : <b>{0}</b>", root.order.id))
End Sub
Public Class RootObject
Public Property id As String
Public Property order As Order
Public Property tender As Tender
Public Property amount As Decimal
Public Property taxAmount As Decimal
Public Property cashbackAmount As Decimal
Public Property employee As Employee
Public Property createdTime As String
Public Property clientCreatedTime As String
Public Property modifiedTime As String
Public Property offline As Boolean
Public Property result As String
Public Property externalReferenceId As String
End Class
Public Class Order
Public Property id As String
End Class
Public Class Tender
Public Property href As String
Public Property id As String
End Class
Public Class Employee
Public Property id As String
End Class
Json
{
"id": "9NNCNGRZ29XA6",
"order": {
"id": "TYF28RDCYBVXP"
},
"tender": {
"href": "https://sandbox.dev.abc.com/v3/merchants/G9G/tenders/DGWC",
"id": "DGW"
},
"amount": 351,
"taxAmount": 0,
"cashbackAmount": 0,
"employee": {
"id": "JCC77XT5H2PCM"
},
"createdTime": 1602824125000,
"clientCreatedTime": 1602824125000,
"modifiedTime": 1602824125000,
"offline": false,
"result": "SUCCESS",
"externalReferenceId": "dc05"
}
Output
Order Id : TYF28RDCYBVXP