Click or drag to resize
Json.NETObjectCreationHandling setting
 

This sample deserializes JSON with ObjectCreationHandling set to Replace so that collection values aren't duplicated.

Sample
Types
 1public class UserViewModel
 2{
 3    public string Name { get; set; }
 4    public IList<string> Offices { get; private set; }
 5
 6    public UserViewModel()
 7    {
 8        Offices = new List<string>
 9        {
10            "Auckland",
11            "Wellington",
12            "Christchurch"
13        };
14    }
15}
Usage
 1string json = @"{
 2  'Name': 'James',
 3  'Offices': [
 4    'Auckland',
 5    'Wellington',
 6    'Christchurch'
 7  ]
 8}";
 9
10UserViewModel model1 = JsonConvert.DeserializeObject<UserViewModel>(json);
11
12foreach (string office in model1.Offices)
13{
14    Console.WriteLine(office);
15}
16// Auckland
17// Wellington
18// Christchurch
19// Auckland
20// Wellington
21// Christchurch
22
23UserViewModel model2 = JsonConvert.DeserializeObject<UserViewModel>(json, new JsonSerializerSettings
24{
25    ObjectCreationHandling = ObjectCreationHandling.Replace
26});
27
28foreach (string office in model2.Offices)
29{
30    Console.WriteLine(office);
31}
32// Auckland
33// Wellington
34// Christchurch