Ejemplo n.º 1
0
        public void CanIgnorePrimitivePropertiesWhenDeserializing()
        {
            string json = @"{
			""sbyteField"": -1,
			""byteField"": 1,
			""shortField"": -1,
			""ushortField"": 1,
			""intField"": -1,
			""uintField"": 1,
			""longField"": -1,
			""ulongField"": 1,
			""decimalField"": 1.0,
			""doubleField"": 1.0,
			""floatField"": 1.0,
			""stringField"": ""value"",
			""boolField"": true
		}"        ;

            PrimitiveIgnoreProperties p_test = JsonMapper.ToObject <PrimitiveIgnoreProperties>(json);

            Assert.AreNotEqual((sbyte)-1, p_test.sbyteField);
            Assert.AreNotEqual((byte)1, p_test.byteField);
            Assert.AreNotEqual((short)-1, p_test.shortField);
            Assert.AreNotEqual((ushort)1, p_test.ushortField);
            Assert.AreNotEqual(-1, p_test.intField);
            Assert.AreNotEqual(1, p_test.uintField);
            Assert.AreNotEqual(-1L, p_test.longField);
            Assert.AreNotEqual(1L, p_test.ulongField);
            Assert.AreNotEqual(1.0M, p_test.decimalField);
            Assert.AreNotEqual(1.0D, p_test.doubleField);
            Assert.AreNotEqual(1.0F, p_test.floatField);
            Assert.AreNotEqual("value", p_test.stringField);
            Assert.AreNotEqual(true, p_test.boolField);
        }
Ejemplo n.º 2
0
        public void CanIgnorePrimitivePropertiesWhenSerializing()
        {
            PrimitiveIgnoreProperties p_test = new PrimitiveIgnoreProperties {
                sbyteField   = -1,
                byteField    = 1,
                shortField   = -1,
                ushortField  = 1,
                intField     = -1,
                uintField    = 1,
                longField    = -1,
                ulongField   = 1,
                decimalField = 1.0M,
                doubleField  = 1.0D,
                floatField   = 1.0F,
                stringField  = "value",
                boolField    = true
            };

            string json = JsonMapper.ToJson(p_test);

            Assert.AreEqual("{}", json);
        }