Hi counterkin,
You need to use where condition in column service_detail which contains pickup.
Please refer below sample.
HTML
<asp:GridView runat="server" ID="gvDetails" />
TextFile
{
"api_status": "Success",
"error_code": "0",
"error_remark": "",
"result": [
{
"REQ_ID": "",
"status": "Success",
"remarks": "",
"rates": [
{
"rate_id": "EP-RR0M2NL",
"service_detail": "dropoff/pickup",
"service_id": "EP-CS0CH",
"service_type": "parcel",
"courier_id": "EP-CR0A",
"courier_logo": "https://s3-ap-southeast-1.amazonaws.com/easyparcel-static/Public/source/general/img/couriers/Pos_Laju.jpg",
"scheduled_start_date": "2020-07-21 Tuesday",
"pickup_date": "2020-07-21",
"delivery": "3-5 working day(s)",
"price": "8.00",
"addon_price": "0.00",
"shipment_price": "8.00",
"require_min_order": 0,
"service_name": "Poslaju Same Day Pick up (within WM)",
"courier_name": "POSLAJU NATIONAL COURIER",
"dropoff_point": [
{
"point_id": "EP-CB0MI",
"point_name": "Pos Malaysia Banting",
"point_contact": "03-3187 1437",
"point_addr1": "No. 101 Jalan Bunga, Pekan 2",
"point_addr2": "42700",
"point_addr3": "",
"point_addr4": "",
"point_postcode": "Banting",
"point_city": "",
"point_state": "sgr",
"start_time": "00:00:00",
"end_time": "00:00:00",
"price": 0
}
],
"pickup_point": []
},
{
"rate_id": "EP-RR0MCOV",
"service_detail": "pickup",
"service_id": "EP-CS0KS",
"service_type": "parcel",
"courier_id": "EP-CR0Z",
"courier_logo": "https://s3-ap-southeast-1.amazonaws.com/easyparcel-static/Public/source/general/img/couriers/CJ_Century.jpg",
"scheduled_start_date": "2020-07-21 Tuesday",
"pickup_date": "2020-07-21",
"delivery": "3-5 working day(s)",
"price": "7.80",
"addon_price": "0.00",
"shipment_price": "7.80",
"require_min_order": 0,
"service_name": "CJ Century",
"courier_name": "CJ Century Logistics Sdn Bhd",
"dropoff_point": [],
"pickup_point": []
},
{
"rate_id": "EP-RR0914N",
"service_detail": "dropoff",
"service_id": "EP-CS09J",
"service_type": "parcel",
"courier_id": "EP-CR0C",
"courier_logo": "https://s3-ap-southeast-1.amazonaws.com/easyparcel-static/Public/source/general/img/couriers/DHLeC.jpg",
"scheduled_start_date": "2020-07-21 Tuesday",
"pickup_date": "2020-07-21",
"delivery": "3-5 working day(s)",
"price": "7.30",
"addon_price": "0.00",
"shipment_price": "7.30",
"require_min_order": 0,
"service_name": "DHL eCommerce (Dropoff only)",
"courier_name": "DHL eCommerce",
"dropoff_point": [
{
"point_id": "EP-CB02X",
"point_name": "DHL ServicePoint - E3 Farmasi",
"point_contact": "",
"point_addr1": "71",
"point_addr2": "Jalan Bunga Tanjung 6A",
"point_addr3": "Taman Muda",
"point_addr4": "",
"point_postcode": "68000",
"point_city": "Ampang",
"point_state": "sgr",
"start_time": "00:00:00",
"end_time": "00:00:00",
"price": 0
}
],
"pickup_point": []
}
],
"pgeon_point": {
"Sender_point": [
{
"point_id": "PGEON_P_TA",
"company": "newsplus",
"point_name": "TES-S ALAM (43)",
"point_contact": "355105643",
"point_lat": "3.07191150",
"point_lon": "101.53883690",
"point_addr1": "LOT 20,1ST FLR TESCO SHAH ALAM,",
"point_addr2": "NO 3 JLN AEROBIK 13/43, SEKSYEN 13,",
"point_addr3": "",
"point_addr4": "",
"point_city": "SHAH ALAM",
"point_state": "sgr",
"point_postcode": "40100",
"price": "0.00"
}
],
"Receiver_point": [
{
"point_id": "PGEON_P_RP",
"company": "newsplus",
"point_name": "RKL-AMP PARK (271)",
"point_contact": "327111975",
"point_lat": "3.15987000",
"point_lon": "101.71910000",
"point_addr1": "AMPANG PARK STATION (UNDERGROUND),",
"point_addr2": "JLN AMPANG,",
"point_addr3": "",
"point_addr4": "",
"point_city": "KUALA LUMPUR",
"point_state": "kul",
"point_postcode": "50450",
"price": "0.00"
}
]
}
}
]
}
Namespace
C#
using System.IO;
VB.Net
Imports System.IO
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string path = Server.MapPath("~/Files/jsonString.txt");
string jsonString = File.ReadAllText(path);
Root jsonArray = Newtonsoft.Json.JsonConvert.DeserializeObject<Root>(jsonString);
Array priceArray = jsonArray.result[0].rates.Where(x => x.service_detail.ToLower().Contains("pickup")).OrderBy(x => x.price).ToArray();
gvDetails.DataSource = priceArray;
gvDetails.DataBind();
}
}
public class DropoffPoint
{
public string point_id { get; set; }
public string point_name { get; set; }
public string point_contact { get; set; }
public string point_addr1 { get; set; }
public string point_addr2 { get; set; }
public string point_addr3 { get; set; }
public string point_addr4 { get; set; }
public string point_postcode { get; set; }
public string point_city { get; set; }
public string point_state { get; set; }
public string start_time { get; set; }
public string end_time { get; set; }
public int price { get; set; }
}
public class PgeonPoint
{
public List<SenderPoint> Sender_point { get; set; }
public List<ReceiverPoint> Receiver_point { get; set; }
}
public class Rate
{
public string rate_id { get; set; }
public string service_detail { get; set; }
public string service_id { get; set; }
public string service_type { get; set; }
public string courier_id { get; set; }
public string courier_logo { get; set; }
public string scheduled_start_date { get; set; }
public string pickup_date { get; set; }
public string delivery { get; set; }
public string price { get; set; }
public string addon_price { get; set; }
public string shipment_price { get; set; }
public int require_min_order { get; set; }
public string service_name { get; set; }
public string courier_name { get; set; }
public List<DropoffPoint> dropoff_point { get; set; }
public List<object> pickup_point { get; set; }
}
public class ReceiverPoint
{
public string point_id { get; set; }
public string company { get; set; }
public string point_name { get; set; }
public string point_contact { get; set; }
public string point_lat { get; set; }
public string point_lon { get; set; }
public string point_addr1 { get; set; }
public string point_addr2 { get; set; }
public string point_addr3 { get; set; }
public string point_addr4 { get; set; }
public string point_city { get; set; }
public string point_state { get; set; }
public string point_postcode { get; set; }
public string price { get; set; }
}
public class Result
{
public string REQ_ID { get; set; }
public string status { get; set; }
public string remarks { get; set; }
public List<Rate> rates { get; set; }
public PgeonPoint pgeon_point { get; set; }
}
public class Root
{
public string api_status { get; set; }
public string error_code { get; set; }
public string error_remark { get; set; }
public List<Result> result { get; set; }
}
public class SenderPoint
{
public string point_id { get; set; }
public string company { get; set; }
public string point_name { get; set; }
public string point_contact { get; set; }
public string point_lat { get; set; }
public string point_lon { get; set; }
public string point_addr1 { get; set; }
public string point_addr2 { get; set; }
public string point_addr3 { get; set; }
public string point_addr4 { get; set; }
public string point_city { get; set; }
public string point_state { get; set; }
public string point_postcode { get; set; }
public string price { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim path As String = Server.MapPath("~/Files/jsonString.txt")
Dim jsonString As String = File.ReadAllText(path)
Dim jsonArray As Root = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Root)(jsonString)
Dim priceArray As Array = jsonArray.result(0).rates.
Where(Function(x) x.service_detail.ToLower().Contains("pickup")).
OrderBy(Function(x) x.price).ToArray()
gvDetails.DataSource = priceArray
gvDetails.DataBind()
End If
End Sub
Public Class DropoffPoint
Public Property point_id As String
Public Property point_name As String
Public Property point_contact As String
Public Property point_addr1 As String
Public Property point_addr2 As String
Public Property point_addr3 As String
Public Property point_addr4 As String
Public Property point_postcode As String
Public Property point_city As String
Public Property point_state As String
Public Property start_time As String
Public Property end_time As String
Public Property price As Integer
End Class
Public Class PgeonPoint
Public Property Sender_point As List(Of SenderPoint)
Public Property Receiver_point As List(Of ReceiverPoint)
End Class
Public Class Rate
Public Property rate_id As String
Public Property service_detail As String
Public Property service_id As String
Public Property service_type As String
Public Property courier_id As String
Public Property courier_logo As String
Public Property scheduled_start_date As String
Public Property pickup_date As String
Public Property delivery As String
Public Property price As String
Public Property addon_price As String
Public Property shipment_price As String
Public Property require_min_order As Integer
Public Property service_name As String
Public Property courier_name As String
Public Property dropoff_point As List(Of DropoffPoint)
Public Property pickup_point As List(Of Object)
End Class
Public Class ReceiverPoint
Public Property point_id As String
Public Property company As String
Public Property point_name As String
Public Property point_contact As String
Public Property point_lat As String
Public Property point_lon As String
Public Property point_addr1 As String
Public Property point_addr2 As String
Public Property point_addr3 As String
Public Property point_addr4 As String
Public Property point_city As String
Public Property point_state As String
Public Property point_postcode As String
Public Property price As String
End Class
Public Class Result
Public Property REQ_ID As String
Public Property status As String
Public Property remarks As String
Public Property rates As List(Of Rate)
Public Property pgeon_point As PgeonPoint
End Class
Public Class Root
Public Property api_status As String
Public Property error_code As String
Public Property error_remark As String
Public Property result As List(Of Result)
End Class
Public Class SenderPoint
Public Property point_id As String
Public Property company As String
Public Property point_name As String
Public Property point_contact As String
Public Property point_lat As String
Public Property point_lon As String
Public Property point_addr1 As String
Public Property point_addr2 As String
Public Property point_addr3 As String
Public Property point_addr4 As String
Public Property point_city As String
Public Property point_state As String
Public Property point_postcode As String
Public Property price As String
End Class
Screenshot