예제 #1
0
        public void CanIgnoreObjectFieldsWhenSerializing()
        {
            ObjectIgnoreFields o_test = new ObjectIgnoreFields {
                dictField   = new Hashtable(),
                listField   = new ArrayList(),
                objectField = new ObjectClass()
            };

            string json = JsonMapper.ToJson(o_test);

            Assert.AreEqual("{}", json);
        }
예제 #2
0
        public void CanIgnoreObjectFieldsWhenDeserializing()
        {
            string json = @"{
			""dictField"": {
				""key"": ""value""
			},
			""listField"": [1, 2, 3],
			""objectField"": {
				""ignored"": true
			}
		}"        ;

            ObjectIgnoreFields o_test = JsonMapper.ToObject <ObjectIgnoreFields>(json);

            Assert.AreEqual(null, o_test.dictField);
            Assert.AreEqual(null, o_test.listField);
            Assert.AreEqual(null, o_test.objectField);
        }