You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
#62 SkipAndReturnBytes should support reader
This commit is contained in:
@ -3,6 +3,8 @@ package jsoniter
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func Test_skip_number(t *testing.T) {
|
||||
@ -75,6 +77,22 @@ func Test_skip_nested(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_skip_and_return_bytes(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := ParseString(ConfigDefault, `[ {"a" : [{"b": "c"}], "d": 102 }, "b"]`)
|
||||
iter.ReadArray()
|
||||
skipped := iter.SkipAndReturnBytes()
|
||||
should.Equal(`{"a" : [{"b": "c"}], "d": 102 }`, string(skipped))
|
||||
}
|
||||
|
||||
func Test_skip_and_return_bytes_with_reader(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := Parse(ConfigDefault, bytes.NewBufferString(`[ {"a" : [{"b": "c"}], "d": 102 }, "b"]`), 4)
|
||||
iter.ReadArray()
|
||||
skipped := iter.SkipAndReturnBytes()
|
||||
should.Equal(`{"a" : [{"b": "c"}], "d": 102 }`, string(skipped))
|
||||
}
|
||||
|
||||
type TestResp struct {
|
||||
Code uint64
|
||||
}
|
||||
|
Reference in New Issue
Block a user