Elasticsearch NEST/C#的序列化错误 [英] Serialization error with Elasticsearch NEST/C#

查看:171
本文介绍了Elasticsearch NEST/C#的序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NEST索引我的对象,并且在序列化时遇到了Newtonsoft错误.我的一个对象有一个自引用循环.我是否可以通过某种方式访问​​JsonSerializer并更改其处理自我引用的方式而无需修改源代码?

I'm using NEST to index my objects and I'm running into a Newtonsoft error on serialization. One of my objects has a self referencing loop. Would there be a way for me to access the JsonSerializer and change how it handles self-references without having to modify the source code?

推荐答案

您可以在客户端上注册自定义转换器:

You can register custom converters on your client:

public void AddConverter(JsonConverter converter)
{
    this.IndexSerializationSettings.Converters.Add(converter);
    this.SerializationSettings.Converters.Add(converter);
}

这可能会有所帮助.

但是,没有直接方法可以更改客户端中使用的JsonSerializerSettings.

There is no direct way to alter the JsonSerializerSettings used in the client though.

这篇关于Elasticsearch NEST/C#的序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆