I am reading data from a graph database and getting the response as a dynamic object. I go through the results and try to deserialize them as so:
var e = results.GetEnumerator();
while (e.MoveNext())
{
var serialized = JsonConvert.SerializeObject(e.Current);
// {"FlagCalculateclientside":[false],"Description":["Some detailed info"], "Name": ["MyDetailedEntity"]}
var val = JsonConvert.DeserializeObject<MyObject>(serialized);
}
public class MyObject
{
public bool FlagCalculateclientside { get; set; }
public string Description { get; set; }
public string Name { get; set; }
}
But I get the following error:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path 'FlagCalculateclientside', line 1, position 28. at Newtonsoft.Json.JsonTextReader.ReadAsBoolean() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) ...
I guess this is because the values are in arrays, but only a single value per key was expected.
Any idea how to fix this?
var results = await gremlinClient.SubmitAsync<dynamic>(requestScript).ConfigureAwait(false);requestScript just holds my Gremlin query string