Serialize json to an object with catch all dictionary property

Viewed 2907

I would like to use JSON.net to deserialize to an object but put unmapped properties in a dictionary property. Is it possible?

For example given the json,

 {one:1,two:2,three:3}

and the c# class:

public class Mapped {
   public int One {get; set;}
   public int Two {get; set;}
   public Dictionary<string,object> TheRest {get; set;}
}

Can JSON.NET deserialize to an instance with values one=1, two=1, TheRest= Dictionary{{"three,3}}

2 Answers
Related