forked from mirror/go-json
Fix encoding of using empty interface as map key
This commit is contained in:
parent
ad04977db7
commit
edd09e7470
|
@ -1912,3 +1912,9 @@ func TestIssue235(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEncodeMapKeyTypeInterface(t *testing.T) {
|
||||||
|
if _, err := json.Marshal(map[interface{}]interface{}{"a": 1}); err == nil {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -486,8 +486,6 @@ func compileKey(ctx *compileContext) (*Opcode, error) {
|
||||||
switch typ.Kind() {
|
switch typ.Kind() {
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
return compilePtr(ctx)
|
return compilePtr(ctx)
|
||||||
case reflect.Interface:
|
|
||||||
return compileInterface(ctx)
|
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
return compileString(ctx)
|
return compileString(ctx)
|
||||||
case reflect.Int:
|
case reflect.Int:
|
||||||
|
|
Loading…
Reference in New Issue