Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-808

GeoJson serializers should coerce numeric values to double during deserialization

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8.3
    • Affects Version/s: 1.8.2
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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] }");
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: