Click or drag to resize
Json.NETMetadataPropertyHandling setting
 

This sample deserializes JSON with MetadataPropertyHandling set to ReadAhead so that metadata properties do not need to be at the start of an object.

Sample
Usage
 1string json = @"{
 2  'Name': 'James',
 3  'Password': 'Password1',
 4  '$type': 'MyNamespace.User, MyAssembly'
 5}";
 6
 7object o = JsonConvert.DeserializeObject(json, new JsonSerializerSettings
 8{
 9    TypeNameHandling = TypeNameHandling.All,
10    // $type no longer needs to be first
11    MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
12});
13
14User u = (User)o;
15
16Console.WriteLine(u.Name);
17// James