public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader); DocumentIdentifier id = new DocumentIdentifier(); MappingBase.Deserialize(id, fieldDict); id.Path = fieldDict.GetStringOrDefault(_PATH); return id; }
public void PASS_Create() { DocumentIdentifier id = new DocumentIdentifier() { Index = IndexSettingEnum.Analyzed, Store = true, Path = "obj.prop" }; Assert.IsNotNull(id); Assert.AreEqual(IndexSettingEnum.Analyzed, id.Index); Assert.AreEqual(true, id.Store); Assert.AreEqual("obj.prop", id.Path); }
public void PASS_Serialize() { DocumentIdentifier id = new DocumentIdentifier() { Index = IndexSettingEnum.Analyzed, Store = true, Path = "obj.prop" }; string json = JsonConvert.SerializeObject(id); Assert.IsNotNull(json); string expectedJson = "{\"index\":\"analyzed\",\"store\":true,\"path\":\"obj.prop\"}"; Assert.AreEqual(expectedJson, json); }