public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Dictionary<string, object> propDict = serializer.Deserialize<Dictionary<string, object>>(reader); DoubleProperty prop = new DoubleProperty(propDict.First().Key); NumberProperty.DeserializeNumber(prop, JsonConvert.DeserializeObject<Dictionary<string, object>>(propDict.First().Value.ToString())); return prop; }
public void PASS_Create() { DoubleProperty prop = new DoubleProperty("doubleme") { PrecisionStep = 5 }; Assert.IsNotNull(prop); Assert.AreEqual("doubleme", prop.Name); Assert.AreEqual((int)5, prop.PrecisionStep); }
public void PASS_Serialize() { DoubleProperty prop = new DoubleProperty("doubleme") { PrecisionStep = 5 }; string json = JsonConvert.SerializeObject(prop); Assert.IsNotNull(json); string expectedJson = "{\"doubleme\":{\"type\":\"double\",\"precision_step\":5}}"; Assert.AreEqual(expectedJson, json); }