You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
suport encode interface
This commit is contained in:
@ -82,13 +82,23 @@ func Test_read_array_with_any_iterator(t *testing.T) {
|
||||
should.Equal([]int{1, 2}, elements)
|
||||
}
|
||||
|
||||
func Test_array_any_get(t *testing.T) {
|
||||
func Test_array_lazy_any_get(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any, err := UnmarshalAnyFromString("[1,[2,3],4]")
|
||||
should.Nil(err)
|
||||
should.Equal(3, any.Get(1,1).ToInt())
|
||||
}
|
||||
|
||||
func Test_array_lazy_any_set(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any, err := UnmarshalAnyFromString("[1,[2,3],4]")
|
||||
should.Nil(err)
|
||||
any.GetArray()[0] = WrapInt64(2)
|
||||
str, err := MarshalToString(any)
|
||||
should.Nil(err)
|
||||
should.Equal("[2,[2,3],4]", str)
|
||||
}
|
||||
|
||||
func Test_invalid_array(t *testing.T) {
|
||||
_, err := UnmarshalAnyFromString("[")
|
||||
if err == nil || err == io.EOF {
|
||||
|
Reference in New Issue
Block a user