How to parse this JSON

This is my Json

{
   "count":2,
   "threads":[
      {
         "thread_id":346568,
         "node_id":75,
         "title":"Giu1ea3i      phu00e1p thu1ed5i bay mu00f9i hu00f4i nu00e1ch tu1ef1 tin hu01a1n trong ngu00e0y hu00e8",
         "reply_count":0,
         "view_count":2,
         "user_id":339597,
         "username":"giangdaigia20",
         "post_date":1434435728,
         "sticky":0,
         "discussion_state":"visible",
         "discussion_open":1,
         "discussion_type":"",
         "first_post_id":2468576,
         "first_post_likes":0,
         "last_post_date":1434435728,
         "last_post_id":2468576,
         "last_post_user_id":339597,
         "last_post_username":"giangdaigia20",
         "prefix_id":2,
         "block_adsense":0,
         "thumbnail_url":"",
         "thumbnail_cache_waindigo":"a:8:{s:13:"thumbnail_url";s:69:"http://trihoinach.org/wp-content/uploads/2015/04/Tri-hoi-nach5555.jpg";s:12:"thumbnailUrl";s:69:"http://trihoinach.org/wp-content/uploads/2015/04/Tri-hoi-nach5555.jpg";s:5:"width";s:2:"48";s:6:"height";s:2:"48";s:9:"max-width";s:2:"48";s:10:"max-height";s:2:"48";s:17:"vertical-position";i:0;s:19:"horizontal-position";i:0;}",
         "custom_fields":[

         ],
         "socia    l_forum_id":0,
         "live_waindigo":0,
         "current_event_id_waindigo":0,
         "google_event_id_waindigo":"",
         "social_forum_title":null,
         "social_forum_user_id":null,
         "social_forum_style_id":null,
         "absolute_url":"http://dev.handheld.vn/threads/346568/"
      },
      {
         "thread_id":346567,
         "node_id":85,
         "title":"Nhu1edd cu00e1c bu00e1c  tu01b0 vu1ea5n du00f9m em 2 cu00e1i u0111u1ed3ng hu1ed3 Citizen nu00e0y",
         "reply_count":1,
         "view_count":4,
         "user_id":156695,
         "username":"gamap",
         "post_date":1434430984,
         "sticky":0,
         "discussion_state":"visible",
         "discussion_open":1,
         "discussion_type":"",
         "first_post_id":2468575,
         "first_post_likes":0,
         "last_post_date":1434443484,
         "last_post_id":2468577,
         "last_post_user_id":156695,
         "last_post_username":"gamap",
         "prefix_id":95,
         "block_adsense":0,
         "thumbnail_url":"",
         "thumbnail_cache_waindigo":"a:8:{s:13:"thumbnail_url";s:86:"http://i16.photobucket.com/albums/b3/vozmember/shopdongho/citizen/real/BU0011-55Aa.jpg";s:12:"thumbnailUrl";s:86:"http://i16.photobucket.com/albums/b3/vozmember/shopdongho/ci    tizen/real/BU0011-55Aa.jpg";s:5:"width";s:2:"48";s:6:"height";s:2:"48";s:9:"max-width";s:2:"48";s:10:"max-height";s:2:"48";s:17:"vertical-position";i:0;s:19:"horizontal-position";i:0;}",
         "custom_fields":[

         ],
         "social_forum_id":0,
         "live_waindigo":0,
         "current_event_id_waindigo":0,
         "google_event_id_waindigo":"",
         "social_forum_title":null,
         "social_forum_user_id":null,
         "social_forum_style_id":null,
         "absolute_url":"http://dev.handheld.vn/threads/34656 7/"
      }
   ]
}

This is my class define

class Thread_Result
{

    public string count { get; set; }
    [JsonProperty("threads")]
    public Threads threads { get; set; }

}

class Threads
{
     [JsonProperty("thread_id")]
    public string thread_id { get; set; }
     [JsonProperty("node_id")]
    public string node_id { get; set; }
      [JsonProperty("title")]
    public string title { get; set; }
      [JsonProperty("reply_count")]
    public string reply_count { get; set; }
      [JsonProperty("view_count")]
    public string view_count { get; set; }
      [JsonProperty("user_id")]
    public string user_id { get; set; }
      [JsonProperty("post_date")]
    public string post_date { get; set; }
      [JsonProperty("sticky")]
    public string sticky { get; set; }
      [JsonProperty("discussion_state")]
    public string discussion_state { get; set; }
     [JsonProperty("discussion_open")]
    public string discussion_open { get; set; }
      [JsonProperty("discussion_type")]
    public string discussion_type { get; set; }
       [JsonProperty("first_post_id")]
    public string first_post_id { get; set; }
      [JsonProperty("first_post_likes")]
    public string first_post_likes { get; set; }
       [JsonProperty("last_post_date")]
    public string last_post_date { get; set; }
     [JsonProperty("last_post_id")]
    public string last_post_id { get; set; }
      [JsonProperty("last_post_user_id")]
    public string last_post_user_id { get; set; }
       [JsonProperty("last_post_username")]
    public string last_post_username { get; set; }
       [JsonProperty("prefix_id")]
    public string prefix_id { get; set; }
       [JsonProperty("block_adsense")]
    public string block_adsense { get; set; }
      [JsonProperty("thumbnail_url")]
    public string thumbnail_url { get; set; }
      [JsonProperty("thumbnail_cache_waindigo")]
    public string thumbnail_cache_waindigo { get; set; }
     [JsonProperty("custom_fields")]
    public string custom_fields { get; set; }
    [JsonProperty("social_forum_id")]
    public string social_forum_id { get; set; }
     [JsonProperty("live_waindigo")]
    public string live_waindigo { get; set; }
     [JsonProperty("current_event_id_waindigo")]
    public string current_event_id_waindigo { get; set; }
        [JsonProperty("google_event_id_waindigo")]
    public string google_event_id_waindigo { get; set; }
          [JsonProperty("social_forum_title")]
    public string social_forum_title { get; set; }
         [JsonProperty("social_forum_user_id")]
    public string social_forum_user_id { get; set; }
         [JsonProperty("social_forum_style_id")]
    public string social_forum_style_id { get; set; }
         [JsonProperty("absolute_url")]
    public string absolute_url { get; set; }
}

But i got error

Cannot deserialize the current JSON object (e.g. {“name”:”value”}) into type ‘System.Collections.Generic.List`1[AppHandHeld.Class.Threads]’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘count’, line 1, position 9.


Source: json

Leave a Reply