mirror of https://github.com/goccy/go-json.git
Merge pull request #244 from goccy/feature/fix-map-key-interface
Fix encoding of using empty interface as map key
This commit is contained in:
commit
a2ba5e8bcc
|
@ -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