Thomas Segato
Thomas Segato

Reputation: 5223

Lowercase Property Names

I am adding a document to Cosmos DB with following line:

client.CreateDocumentAsync(collectionLink, report).Wait();

My c# classes are uppercase however standard json you lowercase properties. Is it possible somehow to ensure this when saving the document?

Upvotes: 1

Views: 1447

Answers (1)

Nick Chapsas
Nick Chapsas

Reputation: 7200

Some of the DocumentClient constructors accept an object called JsonSerializerSettings.

You can provide a different contract resolver there. In your case it's the CamelCasePropertyNamesContractResolver.

var client = new DocumentClient(new Uri(""), "", serializerSettings: new JsonSerializerSettings
    {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
    });

Upvotes: 3

Related Questions