mirror of
https://github.com/json-iterator/go.git
synced 2025-06-06 22:36:25 +02:00
gofmt
This commit is contained in:
parent
55fc498d27
commit
0195110b5b
@ -46,7 +46,6 @@ func ExampleUnmarshal() {
|
|||||||
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func ExampleMarshalWithBestPerformance() {
|
func ExampleMarshalWithBestPerformance() {
|
||||||
type ColorGroup struct {
|
type ColorGroup struct {
|
||||||
ID int
|
ID int
|
||||||
@ -88,4 +87,4 @@ func ExampleUnmarshalWithBestPerformance() {
|
|||||||
fmt.Printf("%+v", animals)
|
fmt.Printf("%+v", animals)
|
||||||
// Output:
|
// Output:
|
||||||
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
type arrayLazyAny struct {
|
type arrayLazyAny struct {
|
||||||
baseAny
|
baseAny
|
||||||
cfg *frozenConfig
|
cfg *frozenConfig
|
||||||
buf []byte
|
buf []byte
|
||||||
err error
|
err error
|
||||||
cache []Any
|
cache []Any
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
type int64LazyAny struct {
|
type int64LazyAny struct {
|
||||||
baseAny
|
baseAny
|
||||||
cfg *frozenConfig
|
cfg *frozenConfig
|
||||||
buf []byte
|
buf []byte
|
||||||
err error
|
err error
|
||||||
cache int64
|
cache int64
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
type objectLazyAny struct {
|
type objectLazyAny struct {
|
||||||
baseAny
|
baseAny
|
||||||
cfg *frozenConfig
|
cfg *frozenConfig
|
||||||
buf []byte
|
buf []byte
|
||||||
err error
|
err error
|
||||||
cache map[string]Any
|
cache map[string]Any
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package jsoniter
|
package jsoniter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -23,7 +23,7 @@ func (cfg *frozenConfig) ReturnStream(stream *Stream) {
|
|||||||
|
|
||||||
func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
|
func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
|
||||||
select {
|
select {
|
||||||
case iter := <- cfg.iteratorPool:
|
case iter := <-cfg.iteratorPool:
|
||||||
iter.ResetBytes(data)
|
iter.ResetBytes(data)
|
||||||
return iter
|
return iter
|
||||||
default:
|
default:
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"encoding"
|
"encoding"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"sort"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type mapDecoder struct {
|
type mapDecoder struct {
|
||||||
@ -151,7 +151,6 @@ func (encoder *sortKeysMapEncoder) encode(ptr unsafe.Pointer, stream *Stream) {
|
|||||||
realInterface := (*interface{})(unsafe.Pointer(&mapInterface))
|
realInterface := (*interface{})(unsafe.Pointer(&mapInterface))
|
||||||
realVal := reflect.ValueOf(*realInterface)
|
realVal := reflect.ValueOf(*realInterface)
|
||||||
|
|
||||||
|
|
||||||
// Extract and sort the keys.
|
// Extract and sort the keys.
|
||||||
var sv stringValues = realVal.MapKeys()
|
var sv stringValues = realVal.MapKeys()
|
||||||
sort.Sort(sv)
|
sort.Sort(sv)
|
||||||
|
@ -2,9 +2,9 @@ package jsoniter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"github.com/json-iterator/go/require"
|
"github.com/json-iterator/go/require"
|
||||||
"testing"
|
"testing"
|
||||||
"encoding/json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_true(t *testing.T) {
|
func Test_true(t *testing.T) {
|
||||||
|
@ -128,11 +128,11 @@ func Test_map_key_with_escaped_char(t *testing.T) {
|
|||||||
|
|
||||||
func Test_encode_map_with_sorted_keys(t *testing.T) {
|
func Test_encode_map_with_sorted_keys(t *testing.T) {
|
||||||
should := require.New(t)
|
should := require.New(t)
|
||||||
m := map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"3": 3,
|
"3": 3,
|
||||||
"1": 1,
|
"1": 1,
|
||||||
"2": 2,
|
"2": 2,
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(m)
|
bytes, err := json.Marshal(m)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
output, err := ConfigCompatibleWithStandardLibrary.MarshalToString(m)
|
output, err := ConfigCompatibleWithStandardLibrary.MarshalToString(m)
|
||||||
|
@ -147,7 +147,7 @@ func Test_string_encode_with_std_without_html_escape(t *testing.T) {
|
|||||||
err := encoder.Encode(input)
|
err := encoder.Encode(input)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
stdOutput := buf.String()
|
stdOutput := buf.String()
|
||||||
stdOutput = stdOutput[:len(stdOutput) - 1]
|
stdOutput = stdOutput[:len(stdOutput)-1]
|
||||||
jsoniterOutputBytes, err := Marshal(input)
|
jsoniterOutputBytes, err := Marshal(input)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
jsoniterOutput := string(jsoniterOutputBytes)
|
jsoniterOutput := string(jsoniterOutputBytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user