17 using Newtonsoft.Json;
18 using Newtonsoft.Json.Linq;
40 public override object ReadJson(JsonReader reader, Type objectType,
object existingValue, JsonSerializer serializer)
42 if (reader.TokenType == JsonToken.StartObject)
44 var jObject = JObject.Load(reader);
47 if (!jObject.ContainsKey(
"y"))
53 if (y !=
null && (y.Type == JTokenType.Float || y.Type == JTokenType.Integer))
55 return new ChartPoint(x.Value<
long>(), y.Value<decimal>());
58 if (y.Type == JTokenType.Null)
66 var jArray = JArray.Load(reader);
67 return new ChartPoint(jArray[0].Value<long>(), jArray[1].Value<decimal?>());
73 public override void WriteJson(JsonWriter writer,
object value, JsonSerializer serializer)
76 writer.WriteStartArray();
77 writer.WriteValue(chartPoint.X);
78 writer.WriteValue(chartPoint.Y);
79 writer.WriteEndArray();