1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-20 11:28:49 +02:00
This commit is contained in:
Tao Wen 2017-06-29 20:40:25 +08:00
parent fb382c0ec1
commit 1253b8edd3
4 changed files with 28 additions and 28 deletions

View File

@ -57,7 +57,7 @@ func (encoder *arrayEncoder) EncodeInterface(val interface{}, stream *Stream) {
return return
} }
elemType := encoder.arrayType.Elem() elemType := encoder.arrayType.Elem()
if encoder.arrayType.Len() == 1 && (elemType.Kind() == reflect.Ptr ||elemType.Kind() == reflect.Map) { if encoder.arrayType.Len() == 1 && (elemType.Kind() == reflect.Ptr || elemType.Kind() == reflect.Map) {
ptr := uintptr(e.word) ptr := uintptr(e.word)
e.word = unsafe.Pointer(&ptr) e.word = unsafe.Pointer(&ptr)
} }

View File

@ -1,11 +1,11 @@
package jsoniter package jsoniter
import ( import (
"encoding"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"unsafe"
"reflect" "reflect"
"encoding" "unsafe"
) )
type stringCodec struct { type stringCodec struct {
@ -419,7 +419,7 @@ func (codec *base64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
} }
encoding := base64.StdEncoding encoding := base64.StdEncoding
src := iter.SkipAndReturnBytes() src := iter.SkipAndReturnBytes()
src = src[1: len(src)-1] src = src[1 : len(src)-1]
decodedLen := encoding.DecodedLen(len(src)) decodedLen := encoding.DecodedLen(len(src))
dst := make([]byte, decodedLen) dst := make([]byte, decodedLen)
len, err := encoding.Decode(dst, src) len, err := encoding.Decode(dst, src)

View File

@ -3,10 +3,10 @@ package jsoniter
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"github.com/json-iterator/go/require" "github.com/json-iterator/go/require"
"io/ioutil" "io/ioutil"
"testing" "testing"
"fmt"
) )
func Test_new_decoder(t *testing.T) { func Test_new_decoder(t *testing.T) {
@ -73,7 +73,7 @@ func Test_use_number_for_unmarshal(t *testing.T) {
func Test_marshal_indent(t *testing.T) { func Test_marshal_indent(t *testing.T) {
t.Skip("WIP") t.Skip("WIP")
should := require.New(t) should := require.New(t)
output, err := json.MarshalIndent(struct{ output, err := json.MarshalIndent(struct {
F1 int F1 int
F2 []int F2 []int
}{1, []int{2, 3, 4}}, "", " ") }{1, []int{2, 3, 4}}, "", " ")