You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When deserializing a json string containing a double in scientific notation (e.g. "{ 'DoubleValue': 2E-05 }") to a BsonDocument, LiteDB.JsonSerializer.Deserialize throws a System.FormatException with "Input string was not in a correct format."
Code to Reproduce
var json = @"{ 'DoubleValue': 2E-05 }";
var doc = LiteDB.JsonSerializer.Deserialize(json).AsDocument;
Expected behavior
A BsonDocument containing a key "DoubleValue" with a value (type double) of 0.00002
Screenshots/Stacktrace
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
at System.Convert.ToInt32(String value, IFormatProvider provider)
at LiteDB.JsonReader.ReadValue(Token token)
at LiteDB.JsonReader.ReadObject()
at LiteDB.JsonReader.ReadValue(Token token)
at LiteDB.JsonReader.Deserialize()
at LiteDB.JsonSerializer.Deserialize(String json)
Additional context
If you add "dbl = true;" in LiteDB.Tokenizer in ReadNumber(ref bool dbl) where _char is checked for 'e' (see screenshot) it solved it for me - doubles were deserialized like a charm. Would you consider that as a fix?
The text was updated successfully, but these errors were encountered:
Version
LiteDB 5.0.8/ Win 10/ .NET Core 3.1
Describe the bug
When deserializing a json string containing a double in scientific notation (e.g. "{ 'DoubleValue': 2E-05 }") to a BsonDocument, LiteDB.JsonSerializer.Deserialize throws a System.FormatException with "Input string was not in a correct format."
Code to Reproduce
Expected behavior
A BsonDocument containing a key "DoubleValue" with a value (type double) of 0.00002
Screenshots/Stacktrace
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
at System.Convert.ToInt32(String value, IFormatProvider provider)
at LiteDB.JsonReader.ReadValue(Token token)
at LiteDB.JsonReader.ReadObject()
at LiteDB.JsonReader.ReadValue(Token token)
at LiteDB.JsonReader.Deserialize()
at LiteDB.JsonSerializer.Deserialize(String json)
Additional context
If you add "dbl = true;" in LiteDB.Tokenizer in ReadNumber(ref bool dbl) where _char is checked for 'e' (see screenshot) it solved it for me - doubles were deserialized like a charm. Would you consider that as a fix?
The text was updated successfully, but these errors were encountered: