public void CanSerializeUnknownProperty() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance); Assert.AreEqual("{\"PropTypeKnown\":\"str\",\"PropTypeUnknown\":{\"unknown\":\"property\"}}", json); }
public void CanRoundTrip() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance, new MyJsonSerializerStrategy()); Assert.AreEqual("{\"prop_type_known\":\"str\",\"prop_type_unknown\":{\"unknown\":\"property\"}}", json); var result = SimpleJson.DeserializeObject<ObjProp>(json, new MyJsonSerializerStrategy()); Assert.AreEqual("str", result.PropTypeKnown); }
public void CanSerializeUnknownPropertyUsingNamingConvention() { var instance = new ObjProp { PropTypeKnown = "str", PropTypeUnknown = new { unknown = "property" } }; var json = SimpleJson.SerializeObject(instance, new MyJsonSerializerStrategy()); Assert.AreEqual("{\"prop_type_known\":\"str\",\"prop_type_unknown\":{\"unknown\":\"property\"}}", json); }