You can create a CustomCreationConverter to do what you need to do. Here's a sample (quite ugly, but demonstrates how you can do this):
namespace JsonConverterTest1 { public class Mapped { private Dictionary<string, object> _theRest = new Dictionary<string, object>(); public int One { get; set; } public int Two { get; set; } public Dictionary<string, object> TheRest { get { return _theRest; } } } public class MappedConverter : CustomCreationConverter<Mapped> { public override Mapped Create(Type objectType) { return new Mapped(); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var mappedObj = new Mapped(); var objProps = objectType.GetProperties().Select(p => p.Name.ToLower()).ToArray();
Thus, the output of mappedObj after deserializing the JSON string will be an object with its One and Two properties, and everything else will be in the Dictionary . Of course, I hard coded the values ββof One and Two as int s, but I think this demonstrates how you do it.
Hope this helps.
EDIT : I updated the code to make it more general. I have not fully tested it, so in some cases when it fails, some problems may arise, but I think that you like it most.
source share