...
1 package any_tests
2
3 import (
4 "github.com/json-iterator/go"
5 "github.com/stretchr/testify/require"
6 "testing"
7 )
8
9 func Test_wrap_map(t *testing.T) {
10 should := require.New(t)
11 any := jsoniter.Wrap(map[string]string{"Field1": "hello"})
12 should.Equal("hello", any.Get("Field1").ToString())
13 any = jsoniter.Wrap(map[string]string{"Field1": "hello"})
14 should.Equal(1, any.Size())
15 }
16
17 func Test_map_wrapper_any_get_all(t *testing.T) {
18 should := require.New(t)
19 any := jsoniter.Wrap(map[string][]int{"Field1": {1, 2}})
20 should.Equal(`{"Field1":1}`, any.Get('*', 0).ToString())
21 should.Contains(any.Keys(), "Field1")
22
23
24 stream := jsoniter.NewStream(jsoniter.ConfigDefault, nil, 0)
25 any.WriteTo(stream)
26
27
28 }
29
View as plain text