1
0
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:
Tao Wen 2017-10-31 22:47:02 +08:00
parent f1258b01aa
commit aed5a81f09
2 changed files with 8 additions and 0 deletions

View File

@ -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)
}

View File

@ -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
}