-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: JSON & ExtJSON
NEW:
If a source extjson document contains a document field that is not represented in the target struct and that document contains a nested document or array, unmarshalling can fail or incorrectly skip too many fields.
ORIGINAL:
The (extJSONValueReader).Skip() method fails when it tries to skip a document that has a document as a child. Specifically, the following test fails on the last line with the error "invalid request to read embedded document":
func TestExtJSONValueReader_Skip(t *testing.T) { vr, err := NewExtJSONValueReader(strings.NewReader(`{"key": {"one": {"two": "three"}}}`), false) if err != nil { t.Fatalf("error creating vr: %v", err) } dr, err := vr.ReadDocument() if err != nil { t.Fatalf("error reading doc: %v", err) } _, vr, err = dr.ReadElement() if err != nil { t.Fatalf("error reading element: %v", err) } err = vr.Skip() if err != nil { t.Fatalf("error skipping: %v", err) } }
That error comes from the extJSONParser.readValue() method which cannot read a whole embedded document. I believe the fix for this is to check in Skip() if the type is an embedded document and handle it appropriately there.
- is duplicated by
-
GODRIVER-1797 Undefined attribute that is an array fails completing unmarshal
- Closed
- related to
-
GODRIVER-1797 Undefined attribute that is an array fails completing unmarshal
- Closed