17 using Newtonsoft.Json;
18 using Newtonsoft.Json.Linq;
19 using System.Collections.Generic;
40 public override void WriteJson(JsonWriter writer,
object value, JsonSerializer serializer)
43 var jObject = JObject.FromObject(orderResponse.Order);
44 jObject[
"symbol"] = JToken.FromObject(orderResponse.Symbol);
45 jObject[
"events"] = JToken.FromObject(orderResponse.Events);
46 jObject.WriteTo(writer);
52 public override object ReadJson(JsonReader reader, Type objectType,
object existingValue, JsonSerializer serializer)
54 var jObject = JObject.Load(reader);
57 var order = jObject.ToObject<
Order>(serializer);
59 var events = jObject[
"Events"] ?? jObject[
"events"];
60 List<SerializedOrderEvent> deserializedEvents =
null;
63 deserializedEvents = events.ToObject<List<SerializedOrderEvent>>();
66 var symbol = jObject[
"Symbol"] ?? jObject[
"symbol"];
67 Symbol deserializedSymbol =
null;
70 deserializedSymbol = symbol.ToObject<
Symbol>();
73 return new ApiOrderResponse(order, deserializedEvents ??
new(), deserializedSymbol);