1
votes

Using Gremlin.Net (3.4.6) and CosmosDB/Graph Upon query, ResultSet of dynamic type is serialized. It is thereafter deserialized to a specific List<> of type Person. Basic vertex values are there, however, the properties' values are empty. I've tried various solutions (including using a Wrapper) without success (the Person objects are null). Using JSON property attribute makes no difference.

Gremlin.Net.Driver.ResultSet<dynamic> result = await ExecuteQuery();
string pList = JsonConvert.SerializeObject(result);     
List<Person> people = JsonConvert.DeserializeObject<List<Person>>(pList);

The pList looks like this: Note that properties members have values in the JSON

Person class is defined as:

public class Person : VertexBase
    {
        [JsonProperty("Name")]
        public VertexProperty<string, NameMeta> Name { get; set; }       
        public string[] PhoneNumbers { get; set; }    
        public int Age { get; set; }

        public Person()
        {         

        }

    }

What is the right way of doing this? Surely it should be something reasonably simple to get at the nested dictionary of properties. The examples do not show deserialization.

1
Please paste the pList stringAsif

1 Answers

0
votes

I faced a similar problem, and I worked around it by explicitly adding a member to my class (Person class in your case) that would contain the Properties dictionary:

    public class PropertyKeyValuePair
    {
        public string Id;
        public string Value;
    }

    public class Person
    {
        // Other fields
        // ...
        public Dictionary<string, PropertyKeyValuePair[]> properties;
    }

The JsonConvert.DeserializeObject function now should be able to deserialize the properties into the properties member.