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

Improve how DataContractJsonSerializer serializes ObjectIds

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.9
    • Affects Version/s: 0.9
    • Component/s: None
    • None
    • Environment:
      Any

      If you have a class Decorated with DataContractAttribute, with a property of type ObjectId decorated with a DataMemberAttribute, and you return it as a response from a call through webHttpBinding (JSON), the property gets serialized as such:

      "Id":

      {"__type":"ObjectId:#MongoDB.Bson","machinePidIncrement":-5429670957678174237,"timestamp":1289430110}

      I think it would make more sense if ObjectId (and BsonObjectId) would be custom serialized to just 4cdb247be076000000001f86 or maybe ObjectId('4cdb247be076000000001f86') for interoptability purposes.

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

              Created:
              Updated:
              Resolved: