Elasticsearch-net: Make Nest.Json.Linq.JArray Public

Created on 28 Mar 2018  路  1Comment  路  Source: elastic/elasticsearch-net

I have a dynamic data model, that requires me to access this class, to perform additional logic before it gets served to the client app. Currently its set to Internal and, thus inaccessible to my implementation and makes thing like dynamic data models somewhat tricky...

public Dictionary<string, object> Attributes { get; set; }

In my service where the documents get created... I can construct something to the effect of

Attributes: {
   "foo":"bar",
   "something": [ "23432", "dsfdsf", "12321" ],
   // at any given time my source system could add other arrays/text items
}

During deserialization, I'm unable to do something like this for example

if (value is Nest.Json.Linq.JArray collection) //  <----- this complains.
{
      value = collection.ToArray<string>();
}

I've tested the above successfully in a sample app, where I emulated this functionality using NewtonSoft.JArray, but of course that doesn't help me much :P

Without the above, the array items get rendered like this in the client:

Attributes: {
   "foo":"bar",
   "something": [ [], [], [] ],
}

I'm open to suggestions, but failing the above, could we please update the Nest.Json.Linq.JArray to be Public?

Most helpful comment

These types are our internalized JSON.NET types where we rewrote the namespace to Nest.Json they are very much intentionally not public, have a gander at our release blog post for the back story here :smile:

https://www.elastic.co/blog/nest-elasticsearch-net-6-0-ga

If you need this types public its best to switch to the Nest.JsonNetSerializer package and configure the client to use it

This way you will get back public Newtonsoft.Json.Linq.JArray's instead 馃憤

>All comments

These types are our internalized JSON.NET types where we rewrote the namespace to Nest.Json they are very much intentionally not public, have a gander at our release blog post for the back story here :smile:

https://www.elastic.co/blog/nest-elasticsearch-net-6-0-ga

If you need this types public its best to switch to the Nest.JsonNetSerializer package and configure the client to use it

This way you will get back public Newtonsoft.Json.Linq.JArray's instead 馃憤

Was this page helpful?
0 / 5 - 0 ratings