public void DoesNotOmitsNullablePropertiesWithAValue() { var item = new { Object = new { Id = 42 }, NullableInt = (int?)1066, NullableBool = (bool?)true }; var json = new SimpleJsonSerializer().Serialize(item); Assert.Equal("{\"object\":{\"id\":42},\"nullable_int\":1066,\"nullable_bool\":true}", json); }
public void OmitsPropertiesWithNullValue() { var item = new { Object = (object)null, NullableInt = (int?)null, NullableBool = (bool?)null }; var json = new SimpleJsonSerializer().Serialize(item); Assert.Equal("{}", json); }
public void HandlesMixingNullAndNotNullData() { var item = new { Int = 42, Bool = true, NullableInt = (int?)null, NullableBool = (bool?)null }; var json = new SimpleJsonSerializer().Serialize(item); Assert.Equal("{\"int\":42,\"bool\":true}", json); }