A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ElasticLINQ/ElasticLINQ/issues/50 below:

Add support for custom JsonSerializerSettings · Issue #50 · ElasticLINQ/ElasticLINQ · GitHub

Hi,

First off, GREAT WORK!!!

Being able to set the JsonSerializerSettings come time to deserialize a JObject in a Hit object would be great.

I found the place the settings need to go in the ElasticQueryTranslator class. The JObject.ToObject method can receive a custom JSonSerializer. Here’s the quick fix we put in place:

private Func<Hit, Object> DefaultItemProjector
{
  get
  {
    return hit => hit._source
      .SelectToken(Mapping.GetDocumentMappingPrefix(sourceType) ?? "")
      .ToObject(sourceType, Newtonsoft.Json.JsonSerializer.Create(new Dell.ComplexConfig.Formatting.V1.CcsSerializerSettings()));
  }
}

I’m guessing that passing the JsonSerializerSettings to the ElasticContext constructor and letting them trickle down would be the way to go.

Any way for us to contribute?

Thanks,

Rene


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4