Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use custom JsonSerializerSettings with DocumentDb in Azure Function

I would like to create a document using the DocumentDb API using custom JsonSerializerSettings. Can anyone tell me how I can do this?

I have tried setting

JsonConvert.DefaultSettings = () => {
    return new JsonSerializerSettings() {
        ContractResolver = new CamelCasePropertyNameContractResolver()
        };
    };
like image 480
phil Avatar asked Jul 24 '17 15:07

phil


Video Answer


1 Answers

The latest DocumentDB SDK (1.15.0) exposes now the JsonSerializerSettings.

You can define your custom settings when you create the DocumentClient instance:

DocumentClient yourClient = new DocumentClient(new Uri("Your Service Endpoint"), "Your Account Key", serializerSettings: new JsonSerializerSettings()
            {
                // Custom settings
            });
like image 174
Matias Quaranta Avatar answered Oct 24 '22 04:10

Matias Quaranta