Hi afrozeameera,
Check this example. Now please take its reference and correct your code.
Namespaces
C#
using System.Net;
using System.Web.Script.Serialization;
VB.Net
Imports System.Net
Imports System.Web.Script.Serialization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
WebClient n = new WebClient();
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var json = n.DownloadString("https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&identifier=SinglePoint¶meters=PRECTOT&startDate=1981&endDate=2019&userCommunity=SSE&tempAverage=INTERANNUAL&outputList=JSON,CSV&lat=15.3173&lon=75.7139");
var serializers = new JavaScriptSerializer();
Temperature temperature = serializers.Deserialize<Temperature>(json);
}
public partial class Temperature
{
public Feature[] features { get; set; }
public Header header { get; set; }
public string[] messages { get; set; }
public Outputs outputs { get; set; }
public ParameterInformation parameterInformation { get; set; }
public object[][] time { get; set; }
public string type { get; set; }
}
public partial class Feature
{
public Geometry geometry { get; set; }
public Properties properties { get; set; }
public string type { get; set; }
}
public partial class Geometry
{
public double[] coordinates { get; set; }
public string type { get; set; }
}
public partial class Properties
{
public Parameter parameter { get; set; }
}
public partial class Parameter
{
public Dictionary<string, double> PRECTOT { get; set; }
}
public partial class Header
{
public string api_version { get; set; }
public long endDate { get; set; }
public long fillValue { get; set; }
public long startDate { get; set; }
public string title { get; set; }
}
public partial class Outputs
{
public string csv { get; set; }
public string json { get; set; }
}
public partial class ParameterInformation
{
public Prectot PRECTOT { get; set; }
}
public partial class Prectot
{
public string longname { get; set; }
public string units { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim n As WebClient = New WebClient()
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Dim json = n.DownloadString("https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&identifier=SinglePoint¶meters=PRECTOT&startDate=1981&endDate=2019&userCommunity=SSE&tempAverage=INTERANNUAL&outputList=JSON,CSV&lat=15.3173&lon=75.7139")
Dim serializers = New JavaScriptSerializer()
Dim temperature As Temperature = serializers.Deserialize(Of Temperature)(json)
End Sub
Partial Public Class Temperature
Public Property features As Feature()
Public Property header As Header
Public Property messages As String()
Public Property outputs As Outputs
Public Property parameterInformation As ParameterInformation
Public Property time As Object()()
Public Property type As String
End Class
Partial Public Class Feature
Public Property geometry As Geometry
Public Property properties As Properties
Public Property type As String
End Class
Partial Public Class Geometry
Public Property coordinates As Double()
Public Property type As String
End Class
Partial Public Class Properties
Public Property parameter As Parameter
End Class
Partial Public Class Parameter
Public Property PRECTOT As Dictionary(Of String, Double)
End Class
Partial Public Class Header
Public Property api_version As String
Public Property endDate As Long
Public Property fillValue As Long
Public Property startDate As Long
Public Property title As String
End Class
Partial Public Class Outputs
Public Property csv As String
Public Property json As String
End Class
Partial Public Class ParameterInformation
Public Property PRECTOT As Prectot
End Class
Partial Public Class Prectot
Public Property longname As String
Public Property units As String
End Class
Screenshot