JsonSerializerSettings

JsonSerializerSettings

本文介绍了在Azure Function中将自定义JsonSerializerSettings与DocumentDb一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用自定义JsonSerializerSettings使用DocumentDb API创建文档.谁能告诉我该怎么做?

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

我尝试设置

JsonConvert.DefaultSettings = () => {
    return new JsonSerializerSettings() {
        ContractResolver = new CamelCasePropertyNameContractResolver()
        };
    };

推荐答案

最新的 DocumentDB SDK (1.15.0)现在公开了JsonSerializerSettings.

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

您可以在创建DocumentClient实例时定义自定义设置:

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
            });

这篇关于在Azure Function中将自定义JsonSerializerSettings与DocumentDb一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 12:32