tags:

views:

84

answers:

1

I am attempting to import a Json string by using:

  AreaField areaField = new AreaField();
  areaField = (AreaField)JsonConvert.Import(typeof(AreaField), HdnData.Value);

The class definition is as follows:

  public class AreaField
  {
    public List<AreaFieldItem> AreaFieldItem { set; get; }
  }

  public class AreaFieldItem
  {
    public string Name { set; get; }

    public bool Required { set; get; }
  }

I get the error:

Cannot import System.Collections.Generic.List`1[FieldItem] from a JSON Array value.

I guess the native implementation of Import does not handle Lists? Do I have deserialize this myself?

A: 

I don't think Jayrock supports generic lists. Try using an AreaFieldItem array instead:

public class AreaField
{
  public AreaFieldItem[] AreaFieldItem { set; get; }
}
kern