Closed mkmik closed 8 years ago
func TestSchemaChange(t *testing.T) { a := struct { Foo string Bar string }{"1", "2"} var b struct { Foo string } data, err := Marshal(&a) if err != nil { t.Fatalf("Marshal: %v", err) } err = Unmarshal(data, &b) if err != nil { t.Fatalf("Unmarshal: %v", err) } }
We get:
decode_test.go:1461: Unmarshal: expected int type, got string
The test passes with encoding/json.
encoding/json
Furthermore if instead of string we use int, the error is even weirder:
string
int
decode_test.go:1461: Unmarshal: JSON decoder out of sync - data changing underfoot?
We get:
The test passes with
encoding/json
.Furthermore if instead of
string
we useint
, the error is even weirder: