Skip to content

Commit 50d163e

Browse files
committed
Address comments
1 parent 639d1f6 commit 50d163e

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

bson/bsonrw/extjson_parser.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,24 +300,26 @@ func (ejp *extJSONParser) readValue(t bsontype.Type) (*extJSONValue, error) {
300300
values: []*extJSONValue{base64, subType},
301301
},
302302
}
303-
} else {
304-
// read KV pairs
305-
if ejp.s != jpsSawBeginObject {
306-
return nil, invalidJSONErrorForType("{", t)
307-
}
303+
break
304+
}
308305

309-
keys, vals, err := ejp.readObject(2, true)
310-
if err != nil {
311-
return nil, err
312-
}
306+
// read KV pairs
307+
if ejp.s != jpsSawBeginObject {
308+
return nil, invalidJSONErrorForType("{", t)
309+
}
313310

314-
ejp.advanceState()
315-
if ejp.s != jpsSawEndObject {
316-
return nil, invalidJSONErrorForType("2 key-value pairs and then }", t)
317-
}
311+
keys, vals, err := ejp.readObject(2, true)
312+
if err != nil {
313+
return nil, err
314+
}
318315

319-
v = &extJSONValue{t: bsontype.EmbeddedDocument, v: &extJSONObject{keys: keys, values: vals}}
316+
ejp.advanceState()
317+
if ejp.s != jpsSawEndObject {
318+
return nil, invalidJSONErrorForType("2 key-value pairs and then }", t)
320319
}
320+
321+
v = &extJSONValue{t: bsontype.EmbeddedDocument, v: &extJSONObject{keys: keys, values: vals}}
322+
321323
case bsontype.DateTime:
322324
switch ejp.s {
323325
case jpsSawValue:

0 commit comments

Comments
 (0)