protected JsonReader() { this._currentState = JsonReader.State.Start; this._dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; this._dateParseHandling = DateParseHandling.DateTime; this._floatParseHandling = FloatParseHandling.Double; this.CloseInput = true; }
/// <summary> /// Initializes a new instance of the <see cref="JsonReader"/> class with the specified <see cref="TextReader"/>. /// </summary> protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; CloseInput = true; }
// Token: 0x06000073 RID: 115 // RVA: 0x00006094 File Offset: 0x00004294 protected JsonReader() { this._currentState = JsonReader.State.Start; this._stack = new List<JsonPosition>(4); this._dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; this._dateParseHandling = DateParseHandling.DateTime; this._floatParseHandling = FloatParseHandling.Double; this.CloseInput = true; }
/// <summary> /// Initializes a new instance of the <see cref="JsonReader"/> class with the specified <see cref="TextReader"/>. /// </summary> protected JsonReader() { _currentState = State.Start; _stack = new List <JsonPosition>(4); _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.None; _floatParseHandling = FloatParseHandling.PreferDecimalFallbackToDouble; CloseInput = true; }
private static void Deserialize(FloatParseHandling fph, Expression expr) { var ser = new JsonSerializer(); using var reader = new JsonExpressionReader(expr) { FloatParseHandling = fph }; ser.Deserialize(reader); }
/// <inheritdoc /> public IAndJsonSerializerSettingsTestBuilder WithFloatParseHandling(FloatParseHandling floatParseHandling) { this.jsonSerializerSettings.FloatParseHandling = floatParseHandling; this.validations.Add((expected, actual) => { if (!CommonValidator.CheckEquality(expected.FloatParseHandling, actual.FloatParseHandling)) { this.ThrowNewJsonResultAssertionException( $"{expected.FloatParseHandling} float parse handling", $"in fact found {actual.FloatParseHandling}"); } }); return(this); }
/// <summary> /// Load a JObject from a string that contains JSON /// </summary> /// <param name="jObject">The jobject parameter</param> /// <param name="json">A string that contains JSON.</param> /// <param name="settings">The JsonLoadSettings used to load the JSON. If this is null, /// default load settings will be used.</param> /// <param name="dateParseHandling">The DateParseHandling settings value</param> /// <param name="timeZoneHandling">The DateTimeZoneHandling settings value</param> /// <param name="floatParseHandling">The FloatParseHandling settings value</param> /// <returns>A JObject populated from the string that contains JSON.</returns> public static JObject Parse(this JObject jObject, string json, JsonLoadSettings settings = null, DateParseHandling dateParseHandling = DateParseHandling.None, DateTimeZoneHandling timeZoneHandling = DateTimeZoneHandling.Unspecified, FloatParseHandling floatParseHandling = FloatParseHandling.Decimal) { using (JsonReader reader = new JsonTextReader(new StringReader(json)) { DateParseHandling = dateParseHandling, DateTimeZoneHandling = timeZoneHandling, FloatParseHandling = floatParseHandling }) { return(JObject.Load(reader, settings)); } }
/// <summary> /// Initializes a new instance of the <see cref="JsonReader"/> class with the specified <see cref="TextReader"/>. /// </summary> protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; CloseInput = true; }
public void SerializeObject_Then_DeserializeObjectAsDictionary_Sample_ShouldMatchJsonNet(FloatParseHandling floatParseHandling, DateParseHandling dateParseHandling) { var obj = CreateObject(); var expectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var expectedSettings = new Newtonsoft.Json.JsonSerializerSettings { FloatParseHandling = Enum.Parse <Newtonsoft.Json.FloatParseHandling>(floatParseHandling.ToString()), DateParseHandling = Enum.Parse <Newtonsoft.Json.DateParseHandling>(dateParseHandling.ToString()), }; var expected = Newtonsoft.Json.JsonConvert.DeserializeObject(expectedJson, typeof(Dictionary <string, object>), expectedSettings); var actualJson = JsonConvert.SerializeObject(obj); var actualSettings = new JsonSerializerSettings { FloatParseHandling = floatParseHandling, DateParseHandling = dateParseHandling, }; var actual = JsonConvert.DeserializeObject(actualJson, typeof(Dictionary <string, object>), actualSettings); JsonDeepEqualAssert.Equal(expected, actual); actual = JsonConvert.DeserializeObject <Dictionary <string, object> >(actualJson, actualSettings); JsonDeepEqualAssert.Equal(expected, actual); }
/// <summary> /// Initializes a new instance of the <see cref="JsonReader"/> class with the specified <see cref="TextReader"/>. /// </summary> protected JsonReader() { _currentState = State.Start; _stack = new List<JsonPosition>(4); _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.PreferDecimalFallbackToDouble; CloseInput = true; }
/// <summary> /// Constructs an <see cref="ObjectConverter"/> with the specified options. /// </summary> /// <param name="floatParseHandling">Specifies how floating point numbers are parsed when reading JSON text.</param> /// <param name="dateParseHandling">Specifies how date formatted strings are parsed when reading JSON text.</param> public ObjectConverter(FloatParseHandling floatParseHandling, DateParseHandling dateParseHandling) { FloatParseHandling = floatParseHandling; DateParseHandling = dateParseHandling; }
private void SetupReader([Nullable(1)] JsonReader reader, out CultureInfo previousCulture, out DateTimeZoneHandling?previousDateTimeZoneHandling, out DateParseHandling?previousDateParseHandling, out FloatParseHandling?previousFloatParseHandling, out int?previousMaxDepth, out string previousDateFormatString) { if (this._culture != null && !this._culture.Equals(reader.Culture)) { previousCulture = reader.Culture; reader.Culture = this._culture; } else { previousCulture = null; } if (this._dateTimeZoneHandling != null) { DateTimeZoneHandling dateTimeZoneHandling = reader.DateTimeZoneHandling; DateTimeZoneHandling?dateTimeZoneHandling2 = this._dateTimeZoneHandling; if (!(dateTimeZoneHandling == dateTimeZoneHandling2.GetValueOrDefault() & dateTimeZoneHandling2 != null)) { previousDateTimeZoneHandling = new DateTimeZoneHandling?(reader.DateTimeZoneHandling); reader.DateTimeZoneHandling = this._dateTimeZoneHandling.GetValueOrDefault(); goto IL_9E; } } previousDateTimeZoneHandling = null; IL_9E: if (this._dateParseHandling != null) { DateParseHandling dateParseHandling = reader.DateParseHandling; DateParseHandling?dateParseHandling2 = this._dateParseHandling; if (!(dateParseHandling == dateParseHandling2.GetValueOrDefault() & dateParseHandling2 != null)) { previousDateParseHandling = new DateParseHandling?(reader.DateParseHandling); reader.DateParseHandling = this._dateParseHandling.GetValueOrDefault(); goto IL_101; } } previousDateParseHandling = null; IL_101: if (this._floatParseHandling != null) { FloatParseHandling floatParseHandling = reader.FloatParseHandling; FloatParseHandling?floatParseHandling2 = this._floatParseHandling; if (!(floatParseHandling == floatParseHandling2.GetValueOrDefault() & floatParseHandling2 != null)) { previousFloatParseHandling = new FloatParseHandling?(reader.FloatParseHandling); reader.FloatParseHandling = this._floatParseHandling.GetValueOrDefault(); goto IL_164; } } previousFloatParseHandling = null; IL_164: if (this._maxDepthSet) { int?maxDepth = reader.MaxDepth; int?maxDepth2 = this._maxDepth; if (!(maxDepth.GetValueOrDefault() == maxDepth2.GetValueOrDefault() & maxDepth != null == (maxDepth2 != null))) { previousMaxDepth = reader.MaxDepth; reader.MaxDepth = this._maxDepth; goto IL_1CA; } } previousMaxDepth = null; IL_1CA: if (this._dateFormatStringSet && reader.DateFormatString != this._dateFormatString) { previousDateFormatString = reader.DateFormatString; reader.DateFormatString = this._dateFormatString; } else { previousDateFormatString = null; } JsonTextReader jsonTextReader = reader as JsonTextReader; if (jsonTextReader != null && jsonTextReader.PropertyNameTable == null) { DefaultContractResolver defaultContractResolver = this._contractResolver as DefaultContractResolver; if (defaultContractResolver != null) { jsonTextReader.PropertyNameTable = defaultContractResolver.GetNameTable(); } } }
private static void Roundtrip(FloatParseHandling fph, params object[] objs) => Roundtrip(expr => new JsonExpressionReader(expr) { FloatParseHandling = fph }, objs);