Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON.net deserializing a complex JSON String into a C# array
    primarykey
    data
    text
    <p>I've been at this for a while and am just getting more and more confused and frustrated. In the following code, I'm trying to deserialize into an array of "observations". I've tried quite a few things and I know that the problem is my model, but I'm stumped on how to get to it. Here is the <a href="http://api.wunderground.com/api/21fd5aec70326254/history_20131218/q/pws%3aKCOBOULD67.json" rel="nofollow">file</a>.</p> <p>Here is the class structure.</p> <pre><code> public class Features { public int history { get; set; } } public class Response { public string version { get; set; } public string termsofService { get; set; } public Features features { get; set; } } public class Date { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Utcdate { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Date2 { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Utcdate2 { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Observation { public Date2 date { get; set; } public Utcdate2 utcdate { get; set; } public string tempm { get; set; } public string tempi { get; set; } public string dewptm { get; set; } public string dewpti { get; set; } public string hum { get; set; } public string wspdm { get; set; } public string wspdi { get; set; } public string wgustm { get; set; } public string wgusti { get; set; } public string wdird { get; set; } public string wdire { get; set; } public string pressurem { get; set; } public string pressurei { get; set; } public string windchillm { get; set; } public string windchilli { get; set; } public string heatindexm { get; set; } public string heatindexi { get; set; } public string precip_ratem { get; set; } public string precip_ratei { get; set; } public string precip_totalm { get; set; } public string precip_totali { get; set; } public string solarradiation { get; set; } public string UV { get; set; } public string softwaretype { get; set; } } public class Date3 { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Utcdate3 { public string pretty { get; set; } public string year { get; set; } public string mon { get; set; } public string mday { get; set; } public string hour { get; set; } public string min { get; set; } public string tzname { get; set; } } public class Dailysummary { public Date3 date { get; set; } public Utcdate3 utcdate { get; set; } public string meantempm { get; set; } public string meantempi { get; set; } public string meandewptm { get; set; } public string meandewpti { get; set; } public string meanwindspdm { get; set; } public string meanwindspdi { get; set; } public string meanwdire { get; set; } public string meanwdird { get; set; } public string humidity { get; set; } public string maxtempm { get; set; } public string maxtempi { get; set; } public string mintempm { get; set; } public string mintempi { get; set; } public string maxhumidity { get; set; } public string minhumidity { get; set; } public string maxdewptm { get; set; } public string maxdewpti { get; set; } public string mindewptm { get; set; } public string mindewpti { get; set; } public string maxpressurem { get; set; } public string maxpressurei { get; set; } public string minpressurem { get; set; } public string minpressurei { get; set; } public string maxwspdm { get; set; } public string maxwspdi { get; set; } public string precipm { get; set; } public string precipi { get; set; } } public class History { public Date date { get; set; } public Utcdate utcdate { get; set; } public List&lt;Observation&gt; observations { get; set; } public List&lt;Dailysummary&gt; dailysummary { get; set; } } public class RootObject { public Response response { get; set; } public History history { get; set; } } </code></pre> <p>I'm getting a Null exception which I know means that something isn't formatted correctly, but I'm fairly new to JSON.net </p> <pre><code>public static void Main (string[] args) { JObject JsonData = JObject.Parse (File.ReadAllText(@"jsontest.json")); JArray Observations = (JArray)JsonData["observations"]; Console.WriteLine (Observations[1].hum); } </code></pre> <p>Any suggestions on how to get this to work? Thanks guys.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload