[CSHARP-3132] Bson regexes Created: 11/Jun/20 Updated: 27/Oct/23 Resolved: 02/Jul/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON, Serialization |
| Affects Version/s: | 2.10.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tomáš Chroboček | Assignee: | Mikalai Mazurenka (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All environments |
||
| Description |
|
Hello. When the regex is value of property in root document there is no problem. The problem seems to be just for nested properties Here is a unit test.
|
| Comments |
| Comment by Mikalai Mazurenka (Inactive) [ 29/Jun/20 ] | |||||||||||||||||||||||
|
Hello muhaha45@gmail.com The second BsonDocument you provided is being deserialized with an exception because its structure mimics the special structures used for serialized JSON regular expressions: For Extended JSON v1 (https://docs.mongodb.com/manual/reference/mongodb-extended-json-v1/#regular-expression)
And for Extended JSON v2 (https://docs.mongodb.com/manual/reference/mongodb-extended-json/#bson.Regular-Expression)
This would happen if you try to construct any special JSON format structures with BSON. The document below would serialize to JSON and deserialize as expected:
So the problem is not in the usage of nested properties. If you would like to produce the Extended JSON v2 output, please use the code snipped below:
And for Extended JSON v1 (this is deprecated output mode, so you have to suppress the warning if you would like to use it):
|