mirror of
https://github.com/json-iterator/go.git
synced 2024-11-27 08:30:57 +02:00
fix #190 handle empty input
This commit is contained in:
parent
f1258b01aa
commit
aed5a81f09
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Any generic object representation.
|
||||
@ -157,6 +158,8 @@ func (iter *Iterator) readAny() Any {
|
||||
return iter.readArrayAny()
|
||||
case '-':
|
||||
return iter.readNumberAny(false)
|
||||
case 0:
|
||||
return &invalidAny{baseAny{}, errors.New("input is empty")}
|
||||
default:
|
||||
return iter.readNumberAny(true)
|
||||
}
|
||||
|
@ -104,6 +104,11 @@ func Test_skip_and_return_bytes_with_reader(t *testing.T) {
|
||||
should.Equal(`{"a" : [{"stream": "c"}], "d": 102 }`, string(skipped))
|
||||
}
|
||||
|
||||
func Test_skip_empty(t *testing.T) {
|
||||
should := require.New(t)
|
||||
should.NotNil(Get([]byte("")).LastError())
|
||||
}
|
||||
|
||||
type TestResp struct {
|
||||
Code uint64
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user