-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 0.1.0
-
Component/s: JSON & ExtJSON
-
None
-
Environment:All
When a number is converted to a string for output to JSON there is a case where the number can be corrupted. This occurs when the number has a single significant digit AND an exponent. For example, the number 3E-5 is corrupted to "3E-5.0". The affected lines are here:
https://github.com/mongodb/mongo-go-driver/blob/master/bson/bson.go#L78
And here:
https://github.com/mongodb/mongo-go-driver/blob/master/bson/bsonrw/extjson_writer.go#L624
This can be fixed this by changing:
if !strings.ContainsRune(s, '.') {
to:
if !strings.ContainsRune(s, 'E') && !strings.ContainsRune(s, '.') {
But maybe there is a better way...