Hi ramco1917,
Please refer below sample.
json
{
"status":true,
"data":
{
"id":"17272102",
"order_id":"31160140",
"order_number":"2003",
"created":"2023-01-11",
"edd":"",
"pickup_date":"",
"rto_initiate_date":"",
"delivered_date":"",
"shipped_date":"",
"awb_number":"81100381950",
"rto_awb":"",
"courier_id":"5",
"warehouse_id":"133763",
"rto_warehouse_id":"133763",
"status":"pending pickup",
"rto_status":"",
"shipment_info":"CAR \/ CMM",
"history":
[
{
"status_code":"PP",
"location":"GURUGRAM (CTY)",
"event_time":"2023-01-11 10:46",
"message":"Online shipment booked"
}
]
}
}
HTML
Data
<asp:GridView ID="gvData" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" />
<asp:BoundField DataField="order_id" HeaderText="order_id" />
<asp:BoundField DataField="order_number" HeaderText="order_number" />
</Columns>
</asp:GridView>
<br />
History
<asp:GridView ID="gvHistory" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="status_code" HeaderText="status_code" />
<asp:BoundField DataField="location" HeaderText="location" />
<asp:BoundField DataField="event_time" HeaderText="event_time" />
<asp:BoundField DataField="message" HeaderText="message" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.IO;
using System.Web.Script.Serialization;
VB.Net
Imports System.IO
Imports System.Web.Script.Serialization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string json = File.ReadAllText(Server.MapPath("~/TextFile.json"));
JavaScriptSerializer serializer = new JavaScriptSerializer();
Root root = serializer.Deserialize<Root>(json);
List<Data> data = new List<Data>();
data.Add(root.data);
gvData.DataSource = data;
gvData.DataBind();
gvHistory.DataSource = data[0].history;
gvHistory.DataBind();
}
public class Data
{
public string id { get; set; }
public string order_id { get; set; }
public string order_number { get; set; }
public string created { get; set; }
public string edd { get; set; }
public string pickup_date { get; set; }
public string rto_initiate_date { get; set; }
public string delivered_date { get; set; }
public string shipped_date { get; set; }
public string awb_number { get; set; }
public string rto_awb { get; set; }
public string courier_id { get; set; }
public string warehouse_id { get; set; }
public string rto_warehouse_id { get; set; }
public string status { get; set; }
public string rto_status { get; set; }
public string shipment_info { get; set; }
public List<History> history { get; set; }
}
public class History
{
public string status_code { get; set; }
public string location { get; set; }
public string event_time { get; set; }
public string message { get; set; }
}
public class Root
{
public string status { get; set; }
public Data data { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim json As String = File.ReadAllText(Server.MapPath("~/TextFile.json"))
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim root As Root = serializer.Deserialize(Of Root)(json)
Dim data As List(Of Data) = New List(Of Data)()
data.Add(root.data)
gvData.DataSource = data
gvData.DataBind()
gvHistory.DataSource = data(0).history
gvHistory.DataBind()
End Sub
Public Class Data
Public Property id As String
Public Property order_id As String
Public Property order_number As String
Public Property created As String
Public Property edd As String
Public Property pickup_date As String
Public Property rto_initiate_date As String
Public Property delivered_date As String
Public Property shipped_date As String
Public Property awb_number As String
Public Property rto_awb As String
Public Property courier_id As String
Public Property warehouse_id As String
Public Property rto_warehouse_id As String
Public Property status As String
Public Property rto_status As String
Public Property shipment_info As String
Public Property history As List(Of History)
End Class
Public Class History
Public Property status_code As String
Public Property location As String
Public Property event_time As String
Public Property message As String
End Class
Public Class Root
Public Property status As String
Public Property data As Data
End Class
Screenshot