mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-06 05:17:38 +03:00
Fix merge objects
This commit is contained in:
parent
b55d1c78b3
commit
2238a05966
3 changed files with 50 additions and 6 deletions
26
common/json/internal/contextjson/keys_test.go
Normal file
26
common/json/internal/contextjson/keys_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package json_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
json "github.com/sagernet/sing/common/json/internal/contextjson"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type MyObject struct {
|
||||
Hello string `json:"hello,omitempty"`
|
||||
MyWorld
|
||||
MyWorld2 string `json:"-"`
|
||||
}
|
||||
|
||||
type MyWorld struct {
|
||||
World string `json:"world,omitempty"`
|
||||
}
|
||||
|
||||
func TestObjectKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
keys := json.ObjectKeys(reflect.TypeOf(&MyObject{}))
|
||||
require.Equal(t, []string{"hello", "world"}, keys)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue