mirror of https://github.com/goccy/go-json.git
Add test case of encoder for json.Number type
This commit is contained in:
parent
16f6c377b4
commit
d0d58b9026
|
@ -3,6 +3,8 @@ package json_test
|
|||
import (
|
||||
"bytes"
|
||||
stdjson "encoding/json"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
func intptr(v int) *int { return &v }
|
||||
|
@ -35,6 +37,8 @@ func boolptr(v bool) *bool { return &v }
|
|||
func boolptr3(v bool) ***bool { vv := &v; vvv := &vv; return &vvv }
|
||||
func bytesptr(v []byte) *[]byte { return &v }
|
||||
func bytesptr3(v []byte) ***[]byte { vv := &v; vvv := &vv; return &vvv }
|
||||
func numberptr(v json.Number) *json.Number { return &v }
|
||||
func numberptr3(v json.Number) ***json.Number { vv := &v; vvv := &vv; return &vvv }
|
||||
func sliceptr(v []int) *[]int { return &v }
|
||||
func arrayptr(v [2]int) *[2]int { return &v }
|
||||
func mapptr(v map[string]int) *map[string]int { return &v }
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -429,6 +429,8 @@ func convertPtrOp(code *Opcode) OpType {
|
|||
return OpBoolPtr
|
||||
case OpBytes:
|
||||
return OpBytesPtr
|
||||
case OpNumber:
|
||||
return OpNumberPtr
|
||||
case OpArray:
|
||||
return OpArrayPtr
|
||||
case OpSlice:
|
||||
|
|
|
@ -2420,7 +2420,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
}
|
||||
if p != 0 {
|
||||
b = appendIndent(ctx, b, code.Indent+1)
|
||||
b = append(b, code.EscapedKey...)
|
||||
b = append(b, ' ')
|
||||
bb, err := appendNumber(b, ptrToNumber(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -2426,7 +2426,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt
|
|||
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
||||
}
|
||||
if p != 0 {
|
||||
b = appendIndent(ctx, b, code.Indent+1)
|
||||
b = append(b, code.Key...)
|
||||
b = append(b, ' ')
|
||||
bb, err := appendNumber(b, ptrToNumber(p))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue