public DefaultJsonSerializer() {
            _serializerSettings = new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                NullValueHandling = NullValueHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Ignore,
                PreserveReferencesHandling = PreserveReferencesHandling.None
            };

            _serializerSettings.Converters.Add(new StringEnumConverter());
            _serializerSettings.Converters.Add(new DataDictionaryConverter());
            _serializerSettings.Converters.Add(new RequestInfoConverter());
        }
Esempio n. 2
0
        // TODO: Ability to deserialize objects without underscores
        //[Fact]
        public void CanDeserializeDataWithoutUnderscores() {
            const string json = @"{""BlahId"":""Hello""}";
            var settings = new JsonSerializerSettings();
            settings.ContractResolver = new LowerCaseUnderscorePropertyNamesContractResolver();

            var m = JsonConvert.DeserializeObject<Blah>(json, settings);
            Assert.Equal("Hello", m.BlahId);

            string newJson = JsonConvert.SerializeObject(m, settings);
        }