[CSHARP-808] GeoJson serializers should coerce numeric values to double during deserialization Created: 27/Aug/13  Updated: 25/Aug/15  Resolved: 28/Aug/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.8.2
Fix Version/s: 1.8.3

Type: Improvement Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The serializers for GeoJson objects are too strict when deserializing and require that numeric values be doubles. They should allow other numeric formats (Int32 and Int64) and convert to double.

For example, given the following class.

public class C
{
    public ObjectId Id { get; set; }
    public GeoJson2DCoordinates Pos { get; set; }
}

the following works:

var c = BsonSerializer.Deserialize<C>("{ Pos : [1.0, 2.0] }");

but the following does not:

var d = BsonSerializer.Deserialize<C>("{ Pos : [1, 2] }");



 Comments   
Comment by Githook User [ 25/Aug/15 ]

Author:

{u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-808: GeoJson serializers should coerce numeric values to double during deserialization.
Branch: v1.8.x
https://github.com/mongodb/mongo-csharp-driver/commit/b984c5aa054d15c2ac29b6a9ac1dddb51ce1d50d

Comment by auto [ 25/Sep/13 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-808: GeoJson serializers should coerce numeric values to double during deserialization.
Branch: v1.8.3
https://github.com/mongodb/mongo-csharp-driver/commit/b984c5aa054d15c2ac29b6a9ac1dddb51ce1d50d

Comment by auto [ 28/Aug/13 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-808: GeoJson serializers should coerce numeric values to double during deserialization.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6cdabf08c239986550a7c98c2da31335a1514125

Comment by Robert Stam [ 28/Aug/13 ]

In code review.

Generated at Wed Feb 07 21:37:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.