[CSHARP-1570] Serialize Guids properly when using Json.NET Created: 12/Feb/16 Updated: 19/Feb/16 Resolved: 19/Feb/16 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Json.NET |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | 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 |
|
Json.NET has a bug that results in Guids being written with the wrong byte order. Write a GuidConverter to work around this. |
| Comments |
| Comment by Robert Stam [ 19/Feb/16 ] |
|
Added a section on using Guids to the documentation for the Json.NET Integration. |
| Comment by Robert Stam [ 17/Feb/16 ] |
|
While working on this two things were discovered: 1. It is actually impossible to write a JsonConverter for Guids because the JsonWriter API has no overloads that allow the caller to specify the binary subtype (not surprising since binary subtype is a BSON-specific concept) 2. The current implementation of BsonWriterAdapter is already handling Guids correctly. It respects the GuidRepresentation configured in the IBsonWriter that it is wrapping. So as long as Json.NET is being used via a JsonSerializerAdapter the Guids will be serialized and deserialized correctly. But if using pure Json.NET they won't be. I've opened a ticket in Json.NET: |