[GODRIVER-562] JSON decoding of an objectid returns error Created: 17/Sep/18  Updated: 28/Oct/23  Resolved: 11/Oct/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 0.0.13
Fix Version/s: 0.0.16

Type: Bug Priority: Major - P3
Reporter: Delio D'Anna Assignee: Go Community User
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Encountered in OSX and Linux but independent from any OS


Issue Links:
Problem/Incident
is caused by GODRIVER-590 objectid.ObjectID should support regu... Closed

 Description   

if an ObjectID is part of a struct and this struct gets marshalled into json it gets converted into an array of integers, which is in line with the specification for json marshalling for an array of bytes. When the bytes are umnarshalled calling json.Unmarshal, however, the objectid.UnmarshalJSON method is called, which errors cause of the following lines:

 
m := make(map[string]string)
err := json.Unmarshal(b, &m)
if err != nil

{     return err }

 
from line 85 of bson/objectid/objectid.go



 Comments   
Comment by Kristofer Brandow (Inactive) [ 11/Oct/18 ]

Code Review: https://github.com/mongodb/mongo-go-driver/pull/97 and https://github.com/mongodb/mongo-go-driver/pull/98.

Comment by Githook User [ 11/Oct/18 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Merge branches 'pr/97' and 'pr/98'

GODRIVER-590
GODRIVER-562

Change-Id: If800aceefac70ad6deb98411a012c32f6a30fa0e
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/97447040cabd95498a3f38bca806d50f76817c77

Comment by Delio D'Anna [ 28/Sep/18 ]

Just a note, not a fix, it seems to work if you use a pointer to an ObjectID

Generated at Thu Feb 08 08:34:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.