Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Add support for custom JsonSerializerSettings #50

Description

@reneherrero

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions