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

JsonConvert.DeserializeObject problem

Oct 12, 2009 at 9:25 AM
Edited Oct 12, 2009 at 10:20 AM


I have the following code and json:



    public class Labels
        public Labels()

        public Label[] Label {get;set;}

    public class Label
        public Label()
        { }
        public string Name { get; set; }
        public int TorrentsInLabel { get; set; }
Labels o = JsonConvert.DeserializeObject<Labels>(json);

I would like this array  ["seq1","1"] to deserialize into Label object. What am I missing? Some attributes?

When I run I get exception: Expected a JsonArrayContract for type 'test_JSONNET.Label', got 'Newtonsoft.Json.Serialization.JsonObjectContract'.



Oct 13, 2009 at 8:02 AM

is this not possible?

Oct 13, 2009 at 8:17 AM

No. Write a JsonConverter for Label if you want it in an array.