Note that there are some explanatory texts on larger screens.

plurals
  1. POJson Parsing in c# using Json.Net
    text
    copied!<pre><code>{"Posts": [{"id":"1", "title":"Bibidh prothom khondo", "content":"sjih sdkljjdsf kdjsfjks", "author":"","last_update":"23 june 2013", "Comments": [{"id":"1", "content":"sjih sdkljjdsf kdjsfjks", "author":"","last_update":"23 june 2013"}]}, {"id":"2", "title":"Bibidh prothom khondo", "content":"sjih sdkljjdsf kdjsfjks", "author":"", "last_update":"24 june 2013", "Comments":[{"id":"1","content":"sjih sdkljjdsf kdjsfjks","author":"","last_update":"23 june 2013"}]},{"id":"3","title":"Bibidh prothom khondo","content":"sjih sdkljjdsf kdjsfjks","author":"","last_update":"25 june 2013"}]} </code></pre> <p>I am trying to parse this json. &amp; For this I my code is: </p> <pre><code>public class Attributes { [JsonProperty("id")] public string ID { get; set; } [JsonProperty("title")] public string TITLE { get; set; } [JsonProperty("content")] public string CONTENT { get; set; } [JsonProperty("author")] public string AUTHOR { get; set; } [JsonProperty("last_update")] public string LAST_UPDATE { get; set; } [JsonProperty("Comments")] public string[] COMMENTS { get; set; } } public class DataJsonAttributeContainer { public List&lt;Attributes&gt; attributes { get; set; } } public static T DeserializeFromJson&lt;T&gt;(string json) { T deserializedProduct = JsonConvert.DeserializeObject&lt;T&gt;(json); return deserializedProduct; } </code></pre> <p>I have tried both of this following way: </p> <pre><code>var container = DeserializeFromJson&lt;DataJsonAttributeContainer&gt;(e.Result); </code></pre> <p>&amp; <code>var container = DeserializeFromJson&lt;List&lt;Attributes&gt;&gt;(e.Result);</code></p> <p>Json string sownloads completely fine but program crashes in while deserializing from json string. I guess, I have made a very silly mistake here &amp; I can not figure it out. Can anyone please help me in this regard? Thanks in advance. </p>
 

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