forked from mirror/go-json
parent
27bd0f2aab
commit
c8d6da88dd
|
@ -2406,3 +2406,21 @@ func TestIssue339(t *testing.T) {
|
||||||
t.Errorf("unexpected result: %v != %v", got, expected)
|
t.Errorf("unexpected result: %v != %v", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue376(t *testing.T) {
|
||||||
|
type Container struct {
|
||||||
|
V interface{} `json:"value"`
|
||||||
|
}
|
||||||
|
type MapOnly struct {
|
||||||
|
Map map[string]int64 `json:"map"`
|
||||||
|
}
|
||||||
|
b, err := json.Marshal(Container{MapOnly{}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got := string(b)
|
||||||
|
expected := `{"value":{"map":null}}`
|
||||||
|
if got != expected {
|
||||||
|
t.Errorf("unexpected result: %v != %v", got, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
if ifacePtr == nil {
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
|
if ifacePtr == nil && !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
|
|
|
@ -3,6 +3,7 @@ package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
if ifacePtr == nil {
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
|
if ifacePtr == nil && !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
|
|
|
@ -3,6 +3,7 @@ package vm_color
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
if ifacePtr == nil {
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
|
if ifacePtr == nil && !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
|
|
|
@ -3,6 +3,7 @@ package vm_color_indent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
if ifacePtr == nil {
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
|
if ifacePtr == nil && !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
|
|
|
@ -3,6 +3,7 @@ package vm_indent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
|
||||||
ifacePtr = iface.ptr
|
ifacePtr = iface.ptr
|
||||||
typ = iface.typ
|
typ = iface.typ
|
||||||
}
|
}
|
||||||
if ifacePtr == nil {
|
isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
|
||||||
|
if ifacePtr == nil && !isDirectedNil {
|
||||||
b = appendNullComma(ctx, b)
|
b = appendNullComma(ctx, b)
|
||||||
code = code.Next
|
code = code.Next
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue