1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-03 23:30:41 +02:00

#146 support config TagKey

This commit is contained in:
Tao Wen
2017-08-22 00:12:09 +08:00
parent ac3b3cd160
commit 2066b01acb
4 changed files with 29 additions and 9 deletions

View File

@ -7,8 +7,6 @@ import (
"testing"
"time"
"unsafe"
"fmt"
"reflect"
)
func Test_customize_type_decoder(t *testing.T) {
@ -307,3 +305,17 @@ func Test_unmarshal_empty_interface_as_int64(t *testing.T) {
Unmarshal([]byte("[100]"), &arr)
should.Equal(int64(100), arr[0])
}
func Test_customize_tag_key(t *testing.T) {
type TestObject struct {
Field string `orm:"field"`
}
should := require.New(t)
json := Config{TagKey: "orm"}.Froze()
str, err := json.MarshalToString(TestObject{"hello"})
should.Nil(err)
should.Equal(`{"field":"hello"}`, str)
}