Serializing graph responses for ASPNetCore Web APIs
I am hitting issues serializing graph responses in .net (with System.Text.Json and Newtonsoft) when the returned data is complex (nested dictionaries with object keys) because the libraries don't know how to serialize the inner dictionary objects. Since the data returned for every query can take different form and shape, I am not sure if I can resolve this using CustomConvertors. How do others handle these generic responses? I was looking into GraphSON and wondering if I should update my service to use that to workaround the serialization problem. Does anyone have recommendations?
3 Replies
Hi vipulkashyap,
What kind of data do you have? For regular nested dictionaries derealization to
dynamic
works without additional convertors, code snippet g.V().HasLabel("big one").Values<dynamic>("big nested property").Next()
Hi Valentyn, here's a sample query and response that is failing serialization. System.Text.Json does not support complex object keys in dictionaries when serializing and Netwonsoft serializes it as:
a workaround could be to use GraphBinary for serialization