6

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()
        };
    };
Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
phil
  • 1,938
  • 4
  • 23
  • 33
  • 1
    Possible duplicate of [Custom serialisation of C# poco's for DocumentDb](https://stackoverflow.com/questions/25864043/custom-serialisation-of-c-sharp-pocos-for-documentdb) – Mikhail Shilkov Jul 24 '17 at 15:56
  • 1
    Also see https://stackoverflow.com/questions/37489768/how-to-tell-documentdb-sdk-to-use-camelcase-during-linq-query – Mikhail Shilkov Jul 24 '17 at 15:57

1 Answers1

5

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
            });
Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47