[GODRIVER-2017] UnmarshalExtJSON with error Created: 20/May/21 Updated: 28/Oct/23 Resolved: 28/May/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | JSON & ExtJSON |
| Affects Version/s: | None |
| Fix Version/s: | 1.5.3 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | 杰 王 | Assignee: | Benji Rewis (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Documentation Changes: | Not Needed |
| Comments |
| Comment by Benji Rewis (Inactive) [ 28/May/21 ] |
|
feys1992@gmail.com this fix is now merged and should available in the next patch of the Go driver. |
| Comment by Githook User [ 28/May/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: |
| Comment by Githook User [ 28/May/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: |
| Comment by Benji Rewis (Inactive) [ 26/May/21 ] |
|
Thanks again for the report, feys1992@gmail.com! We've determined this is a bug. If a field with an empty object ("y" in your case) is undefined in the destination struct and is followed by another object ("rule_group_id" in your case), that following object will be unmarshaled as empty. This was because we were not setting a flag for empty objects back to false when skipping with skipObject. A fix is in review now: https://github.com/mongodb/mongo-go-driver/pull/677. |
| Comment by Benji Rewis (Inactive) [ 24/May/21 ] |
|
Hello feys1992@gmail.com! Thanks so much for your report; we're trying to reproduce this error now. |
| Comment by 杰 王 [ 20/May/21 ] |
|
package mainpackage main ,"x":"1006007-154305-18344992668-17136650599","y":{},"z":0,"rule_group_id":{"$oid":"5ff599d4fa3f7f0012d5d3d0"},"m":""}` {} err := bson.UnmarshalExtJSON([]byte(doc), false, &foo) require.NoError(t, err) require.Equal(t, "5ff5b89ecbc9590001210d5b", foo.ID.Hex()) require.Equal(t, "000000000000000000000000", foo.RuleGroupID.Hex()) }) |