Deserialization of json string

Mar 15, 2011 at 2:52 PM
Edited Mar 15, 2011 at 2:55 PM

Hey Guys,

i try to deserialize a received json String:



{"result": {"number_of_favourites": 4, "number_of_messages": 9, "user_first_name": "Lukas"}, "id": "djangorpc", "error": null}



The deserialization of the strings works pretty good, but i have a problem to get the array of "result".

I 've tried this, but it doesn't work.

User p2 = js.Deserialize<User>(json); Trace.WriteLine("ID:"; Trace.WriteLine("test:" + p2.tokens.Count);

This is the User Class:

public class User
        public string id { get; set;}
        public List<result> tokens { get; set; }

        public User()
            tokens = new List<result>();

    public class result
        public int number_of_favourites { get; set; }
        public int number_of_messages { get; set; }
        public string user_first_name { get; set; }

How can i get the "result" array of the JsonString in C# ?

Hope somebody can give me a hint ...