I have the following dynamic object that I'm getting from a third party library:
IOrderStore os = ss.GetService<IOrderStore>();
IOrderInfo search = os.Orders.Where(t => t.Number == "test").FirstOrDefault();
IOrder orderFound = os.OpenOrder(search, true);
dynamic order = (dynamic)orderFound;
dynamic requirements = order.Title.Commitments[0].Requirements;
I need to parse it to a JSON string.
I tried this (using JSON.net):
string jsonString = JsonConvert.SerializeObject(requirements);
return jsonString;
But I get a seemingly corrupted JSON string, as below:
[{"$id":"1"},{"$id":"2"},{"$id":"3"},{"$id":"4"},{"$id":"5"},{"$id":"6"},{"$id":"7"},{"$id":"8"},{"$id":"9"},{"$id":"10"},{"$id":"11"},{"$id":"12"},{"$id":"13"},{"$id":"14"},{"$id":"15"}]
The object contains multiple properties, and not just the 'id'.
Any advice?
Requirementsis created because when just simply testing a list of dynamic objects and each with several fields they are all serializedRequirementsproperty in order to help you.Console.WriteLine(order.Title.Commitments[0].Requirements.GetType());print? Show us that string, please. Also, you keep saying you are using a third party library. Which library? Is there documentation available? And most importantly: how you you know the returned JSON is "corrupted", as you say? What is your reference? What exactly do you expect to see?