Hi nauna,
Using the DLL from here i have created sample.
http://james.newtonking.com/json/help/index.html
NameSpace
using Newtonsoft.Json;
Code
protected void Page_Load(object sender, EventArgs e)
{
string page = "https://api.postcodes.io/postcodes/L33AN";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(page);
//&tracking_number=" + txtttnumber.Text + "&courier=" + ddlcourier.SelectedValue
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
readStream = new StreamReader(receiveStream);
else
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
string data = readStream.ReadToEnd();
dynamic obj = JsonConvert.DeserializeObject(data);
List<string> results = new List<string>();
for (int i = 1; i < obj.Count; i++)
{
results.Add(((Newtonsoft.Json.Linq.JObject)(((Newtonsoft.Json.Linq.JContainer)((obj["result"]))))).ToString());
}
List<Results> mapList = new List<Results>();
foreach (string item in results)
{
Results root = JsonConvert.DeserializeObject<Results>(item);
Results map = new Results()
{
PostCode = root.PostCode,
Latitude = root.Latitude,
Longitude = root.Longitude
};
mapList.Add(map);
}
GridView1.DataSource = mapList;
GridView1.DataBind();
}
}
public class Results
{
public string PostCode { get; set; }
public string Longitude { get; set; }
public string Latitude { get; set; }
}
HTML
<asp:GridView runat="server" ID="GridView1">
</asp:GridView>
Output
PostCode | Longitude | Latitude |
L3 3AN |
-2.9796136353518 |
53.4161140793062 |