Skip to content

Custom JSON options

Sometimes we may have a class that needs custom serialization settings e.g. the use of a JsonStringEnumConverter. The following example needs to use that to get a string value for an enum value to be deserialized.

Note

The resource used in this example can be found here

var theObject = ResourceHelper
    .ReadJsonResource<JsonTestClassWithEnum>(c => c
        .ConfigureJsonDeserializerOptions(
            c => c.Converters.Add(new JsonStringEnumConverter())
        )
    );

// theObject will have a Name of "OtherAls", Answer of "No" and Age of 10