/// <summary> /// Creates a set of <see cref="JsonSerializerSettings"/> suitable for specifying in /// <see cref="BigqueryService"/> construction. The settings have Json.NET date parsing /// detection disabled. /// </summary> /// <returns>A suitable set of settings.</returns> public static JsonSerializerSettings CreateJsonSerializersSettings() { JsonSerializerSettings settings = NewtonsoftJsonSerializer.CreateDefaultSettings(); settings.DateParseHandling = DateParseHandling.None; return(settings); }
public void CreateDefaultSettings_Independent() { var settings1 = NewtonsoftJsonSerializer.CreateDefaultSettings(); var settings2 = NewtonsoftJsonSerializer.CreateDefaultSettings(); settings1.DateParseHandling = DateParseHandling.DateTimeOffset; settings2.DateParseHandling = DateParseHandling.None; // Not affected by changing settings2 Assert.Equal(DateParseHandling.DateTimeOffset, settings1.DateParseHandling); }
public void CustomInstanceAvoidingDateParsin() { string text = "\"2017-05-03T16:38:00Z\""; var settings = NewtonsoftJsonSerializer.CreateDefaultSettings(); settings.DateParseHandling = DateParseHandling.None; var instance = new NewtonsoftJsonSerializer(settings); object value = instance.Deserialize <object>(text); // No magic parsing to DateTime... Assert.IsType <string>(value); }