Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1015 Bytes

DeserializeMetadataPropertyHandling.md

File metadata and controls

29 lines (24 loc) · 1015 Bytes

MetadataPropertyHandling setting

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

var json = """
    {
      'Name': 'James',
      'Password': 'Password1',
      '$type': 'MyNamespace.User, MyAssembly'
    }
    """;

var o = JsonConvert.DeserializeObject(json, new JsonSerializerSettings
{
    TypeNameHandling = TypeNameHandling.All,
    // $type no longer needs to be first
    MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead
});

var u = (User) o;

Console.WriteLine(u.Name);
// James

snippet source | anchor