0

I get this JSON from Box API call:

   {"total_count":4,
    "entries":[
        {"type":"folder","id":"3102883693","sequence_id":"0","etag":"0","name":"Deployments"},            
        {"type":"folder","id":"3460455852","sequence_id":"0","etag":"0","name":"MARKETING"},
        {"type":"folder","id":"2535410485","sequence_id":"1","etag":"1","name":"Plans"},
        {"type":"folder","id":"3132381455","sequence_id":"0","etag":"0","name":"Projects"}, 
        ],
    "offset":0,
    "limit":100,
    "order":[
        {"by":"type","direction":"ASC"},
        {"by":"name","direction":"ASC"}
        ]
    }

I tried this to get it into class but I cant get my list:

var folders = new JavaScriptSerializer().Deserialize<List<FolderItems>>(response.Content);

Here are my classes:

   public class FolderItems
   {
       public int total_count { get; set; }
       public List<Entry> entries { get; set; }
       public int offset { get; set; }
       public int limit { get; set; }
       public List<Order> order { get; set; }
   }
    public class Entry
    {
        public string type { get; set; }
        public int id { get; set; }
        public int sequence_id { get; set; }
        public string etag { get; set; }
        public string name { get; set; }
    }

public class Order
{
    public string by { get; set; }
    public string direction { get; set; }
}
1
  • My folders list is empty Commented May 19, 2015 at 23:53

1 Answer 1

3

Based on your JSON, you have a single outer object, not a list.

var folder = new JavaScriptSerializer().Deserialize<FolderItems>(response.Content);

You should be deserializing into a single FolderItems object with a list of entries on that object.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.