[GODRIVER-711] Encoding nil type (like bson.D(nil)) encodes as nil Created: 17/Dec/18 Updated: 27/Oct/23 Resolved: 17/Dec/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Eric Daniels (Inactive) | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
In mgo.v2/bson, this encoded as a an empty document which seems more idiomatic. |
| Comments |
| Comment by Eric Daniels (Inactive) [ 17/Dec/18 ] |
|
Okay then we should just point it out in the migration guide! Will close. This caused me some confusion for a bit in some tests. |
| Comment by Kristofer Brandow (Inactive) [ 17/Dec/18 ] |
|
The encoding/json package encodes a nil array or map as null not as an empty array or object. We feel that this aligns better with the idioms of Go since a nil slice is different from an allocated slice with length zero. |