I have difficulty with nested json
such as get api data from web site and posted to the database
Here is the nested json im trying to send the data to my local tables pulling the data from external site "https://samples.openweathermap.org/data/2.5/weather?zip=94040,us&appid=b6907d289e10d714a6e88b30761fae22",
In this code i tried to post data to mt tables but all fields recive null ,and the only field thats gets pupulated is the ids
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$.ajax({
url: "api/RootObjects",
dataType: 'text',
type: 'post',
contentType: 'application/x-www-form-urlencoded',
data: "https://samples.openweathermap.org/data/2.5/weather?zip=94040,us&appid=b6907d289e10d714a6e88b30761fae22",
success: function( data, textStatus, jQxhr ){
alert(data);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
}
});
</script>
namespace WebApplication5
{
public class Coord
{
public double lon { get; set; }
public double lat { get; set; }
public int id { get; set; }
}
public class Weather
{
public int id { get; set; }
public string main { get; set; }
public string description { get; set; }
public string icon { get; set; }
}
public class Main
{
public double temp { get; set; }
public int pressure { get; set; }
public int humidity { get; set; }
public double temp_min { get; set; }
public double temp_max { get; set; }
public int id { get; set; }
}
public class Wind
{
public int id { get; set; }
public double speed { get; set; }
public int deg { get; set; }
public double gust { get; set; }
}
public class Clouds
{
public int all { get; set; }
public int id { get; set; }
}
public class Sys
{
public int type { get; set; }
public int id { get; set; }
public double message { get; set; }
public string country { get; set; }
public int sunrise { get; set; }
public int sunset { get; set; }
}
public class RootObject
{
public int id { get; set; }
public Coord coord { get; set; }
public List<Weather> weather { get; set; }
public string bbase { get; set; }
public Main main { get; set; }
public int visibility { get; set; }
public Wind wind { get; set; }
public Clouds clouds { get; set; }
public int dt { get; set; }
public Sys sys { get; set; }
public string name { get; set; }
public int cod { get; set; }
}
}