Skip to content

HandleNestTypesOnSourceJsonConverter does not serialize/deserialize the join field as expected #3356

Closed
@ghost

Description

NEST/Elasticsearch.Net version: 6.2.0

Elasticsearch version: 6.x

Description of the problem including expected versus actual behavior:

HandleNestTypesOnSourceJsonConverter does not serialize/deserialize the join field as expected.

"myparent" vs "\"myparent\""

Steps to reproduce:

  1. Check attached source code
            var parentDocument = new MyParent
            {
                Id = 1,
                ParentProperty = "a parent prop",
                MyJoinField = "myparent"
            };

            var settings = new JsonSerializerSettings();
            settings.Converters.Add(new HandleNestTypesOnSourceJsonConverter(((IConnectionSettingsValues)connectionSettings).RequestResponseSerializer));

            var json01 = Newtonsoft.Json.JsonConvert.SerializeObject(parentDocument, Formatting.Indented, settings);
            var back01 = Newtonsoft.Json.JsonConvert.DeserializeObject<MyParent>(json01, settings);

            var json02 = Newtonsoft.Json.JsonConvert.SerializeObject(back01, Formatting.Indented, settings);

            Console.WriteLine($"JSON01: {json01}");
            Console.WriteLine($"JSON02: {json02}");
  1. Result

    JSON01: {
        "ParentProperty": "a parent prop",
        "Id": 1,
        "MyJoinField": "myparent"
    }
    JSON02: {
        "ParentProperty": "a parent prop",
        "Id": 1,
        "MyJoinField": "\"myparent\""
    }

Note: This is causing a lot of troubles for as as we use to serialize/deserialize to send documents between micro services.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions