views:

12

answers:

0

How can I deserialize JSON string into entity of type like this (self-tracking properties removed to be simple):

public class User: 
{
    int Id { get; set; }
    string Name { get; set; }
    public TrackableCollection<Role> Roles { get; set; } // <!
}

Role is also simple class with two properties. TrackableCollection is descendant of Collection (System.Collections.ObjectModel).

So I want: having JSON string like this

{"Id":0, "Name":"Test User", "Roles": [{"Id":1, "Name": "Role 1"}, {"Id":2, "Name": "Role 2"}, {"Id":3, "Name": "Role 3"}]}

get entity with correctly deserialized Roles collection.