This project has moved. For the latest updates, please go here.

How to deserialize JSON array into array of .NET objects

May 2, 2010 at 2:24 PM

How would i take a json string like this:

{"count":3,"items":[{"id":"4","priority":"3","subject":"Another message","message":"adsfasdf"},
:"2","priority":"3","subject":"testing again","message":"just seeing ow "},

and turn it into a .NET class holding items as an array of Items classes?
May 2, 2010 at 11:22 PM

Simplest solution would be to create a class like this:


public class ItemContainer


  public int Count { get; set; }

  public IList<Item> Items { get; set; }



Deserialize to that and then get the collection of items from the Items property.

May 3, 2010 at 1:03 AM

How would the attributes need to be for deserialization? Also, other than the documentation provided, is there any place to learn how to use JSON.Net? The documentation wasn't really helpful in learning it. I actually really don't know what i'm doing at all. :-(